diff --git a/dune/common/std/mdspan.hh b/dune/common/std/mdspan.hh index 30394cf44ca5ce6a86fb74b35115f9508149b0d7..1c65e26bca87805ee16071b82429f918248a3a89 100644 --- a/dune/common/std/mdspan.hh +++ b/dune/common/std/mdspan.hh @@ -168,10 +168,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 diff --git a/dune/common/std/test/mdspantest.cc b/dune/common/std/test/mdspantest.cc index c07ca26120182358c147c1b0a3c057218a7b84fb..d4e7e332b5bce17bd473f813897eb600810abbf7 100644 --- a/dune/common/std/test/mdspantest.cc +++ b/dune/common/std/test/mdspantest.cc @@ -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); }