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

Merge branch 'issue/mdarray-to-mdspan' into 'master'


Fix mdspan converting constructor

See merge request !1522

(cherry picked from commit a7da5ef8)

2c0dda20 Fix mdspan converting constructor
7c72f546 Add test for the converting constructor

Co-authored-by: default avatarChristoph Grüninger <gruenich@dune-project.org>
parent 67db40f2
No related branches found
No related tags found
1 merge request!1523[backport] Merge branch 'issue/mdarray-to-mdspan' into 'master'
Pipeline #77781 waiting for manual action
......@@ -167,10 +167,10 @@ public:
/// \brief Converting constructor
template <class OtherElementType, class OtherExtends, class OtherLayoutPolicy, class OtherAccessor,
std::enable_if_t<std::is_constructible_v<mapping_type, const typename OtherElementType::template mapping<OtherExtends>&>, int> = 0,
std::enable_if_t<std::is_constructible_v<mapping_type, const typename OtherLayoutPolicy::template mapping<OtherExtends>&>, int> = 0,
std::enable_if_t<std::is_constructible_v<accessor_type, const OtherAccessor&>, int> = 0>
#if __cpp_conditional_explicit >= 201806L
explicit(!std::is_convertible_v<const typename OtherElementType::template mapping<OtherExtends>&, mapping_type>
explicit(!std::is_convertible_v<const typename OtherLayoutPolicy::template mapping<OtherExtends>&, mapping_type>
|| !std::is_convertible_v<const OtherAccessor&, accessor_type>)
#endif
constexpr mdspan (const mdspan<OtherElementType,OtherExtends,OtherLayoutPolicy,OtherAccessor>& other) noexcept
......
......@@ -83,6 +83,11 @@ void test_accessor (Dune::TestSuite& testSuite, std::string name, const M& mappi
else if constexpr(Span::rank() == 3)
Span span5{dh, e.extent(0), e.extent(1), e.extent(2)};
// converting constructor
using OtherExtents = Dune::Std::dextents<std::size_t, Span::rank()>;
using OtherSpan = Dune::Std::mdspan<typename A::element_type, OtherExtents, typename M::layout_type, A>;
OtherSpan otherSpan(span4);
checkAccess(subTestSuite, span2);
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