Skip to content
Snippets Groups Projects
Commit b5f6c38e authored by Simon Praetorius's avatar Simon Praetorius
Browse files

Generalize the Span argument

parent 26a834a8
No related branches found
No related tags found
No related merge requests found
Pipeline #73560 failed
......@@ -124,7 +124,11 @@ public:
});
* \endcode
**/
constexpr Tensor (Std::span<IndexType,ExtentsType::rank()> e,
template <class OtherIndexType, std::size_t N,
std::enable_if_t<std::is_convertible_v<const OtherIndexType&, IndexType>, int> = 0,
std::enable_if_t<std::is_nothrow_constructible_v<IndexType,const OtherIndexType&>, int> = 0,
std::enable_if_t<(N == ExtentsType::rank_dynamic() || N == ExtentsType::rank()), int> = 0>
constexpr Tensor (Std::span<OtherIndexType,N> e,
NestedInitializerList_t<ValueType,ExtentsType::rank()> init)
: Tensor{MappingType{ExtentsType{e}}, init}
{}
......
......@@ -54,6 +54,17 @@ protected:
/// Derive constructors from base class
using BaseType::BaseType;
/// \brief base copy constructor
constexpr TensorMixin (const BaseType& tensor)
: BaseType{tensor}
{}
/// \brief base move constructor
constexpr TensorMixin (BaseType&& tensor)
: BaseType{std::move(tensor)}
{}
public:
/// \name Multi index access
/// @{
......
......@@ -38,7 +38,8 @@ class TensorSpan
Std::mdspan<Element,Extents,Layout,Accessor>>
{
using SelfType = TensorSpan;
using BaseType = TensorMixin<SelfType, Std::mdspan<Element,Extents,Layout,Accessor>>;
using StorageType = Std::mdspan<Element,Extents,Layout,Accessor>;
using BaseType = TensorMixin<SelfType,StorageType>;
public:
using ElementType = Element;
......@@ -72,12 +73,12 @@ public:
{}
/// \brief base copy constructor
constexpr TensorSpan (const BaseType& tensor)
constexpr TensorSpan (const StorageType& tensor)
: BaseType{tensor}
{}
/// \brief base move constructor
constexpr TensorSpan (BaseType&& tensor)
constexpr TensorSpan (StorageType&& tensor)
: BaseType{std::move(tensor)}
{}
......
......@@ -10,6 +10,7 @@
#include <dune/common/fmatrix.hh>
#include <dune/common/hybridutilities.hh>
#include <dune/common/tensor.hh>
#include <dune/common/tensorspan.hh>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/common/test/testsuite.hh>
#include <dune/common/test/foreachindex.hh>
......@@ -115,7 +116,7 @@ void checkConstructors(Dune::TestSuite& testSuite)
}
Tensor tensor9(tensor1.to_mdspan());
Tensor tensor9(TensorSpan{tensor1.to_mdspan()});
testSuite.subTest(subTestSuite);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment