From f206c7395c6880ded75da5d6b742ec1c6c8e44df Mon Sep 17 00:00:00 2001 From: Christian Trott Date: Wed, 1 Feb 2023 15:42:13 -0700 Subject: [PATCH] Clang-format --- .../experimental/__p0009_bits/extents2.hpp | 622 +++++++++--------- 1 file changed, 302 insertions(+), 320 deletions(-) diff --git a/include/experimental/__p0009_bits/extents2.hpp b/include/experimental/__p0009_bits/extents2.hpp index 0741e7fb..5f0aba09 100644 --- a/include/experimental/__p0009_bits/extents2.hpp +++ b/include/experimental/__p0009_bits/extents2.hpp @@ -13,84 +13,78 @@ namespace detail { // Function used to check compatibility of extents in converting constructor // can't be private member functions for some reason - template - static constexpr std::integral_constant __check_compatible_extents( - std::integral_constant, std::integer_sequence, std::integer_sequence - ) noexcept { return { }; } - - template - static constexpr std::integral_constant< - bool, - _MDSPAN_FOLD_AND( - ( - Extents == dynamic_extent - || OtherExtents == dynamic_extent - || Extents == OtherExtents - ) /* && ... */ - ) - > - __check_compatible_extents( - std::integral_constant, std::integer_sequence, std::integer_sequence - ) noexcept { return { }; } +template +static constexpr std::integral_constant __check_compatible_extents( + std::integral_constant, + std::integer_sequence, + std::integer_sequence) noexcept { + return {}; +} +template +static constexpr std::integral_constant< + bool, _MDSPAN_FOLD_AND((Extents == dynamic_extent || + OtherExtents == dynamic_extent || + Extents == OtherExtents) /* && ... */ + )> +__check_compatible_extents( + std::integral_constant, + std::integer_sequence, + std::integer_sequence) noexcept { + return {}; +} // Implementation of Static Array, recursive implementation of get -template -struct static_array_impl; +template struct static_array_impl; -template +template struct static_array_impl { MDSPAN_INLINE_FUNCTION constexpr static T value(size_t r) { - if(r==R) return FirstExt; - else return static_array_impl::value(r); + if (r == R) + return FirstExt; + else + return static_array_impl::value(r); } - template - MDSPAN_INLINE_FUNCTION - constexpr static T get() { + template MDSPAN_INLINE_FUNCTION constexpr static T get() { #if MDSPAN_HAS_CXX_17 - if constexpr (r==R) return FirstExt; - else return static_array_impl::template get(); + if constexpr (r == R) + return FirstExt; + else + return static_array_impl::template get(); #else - if(r==R) return FirstExt; - else return static_array_impl::value(r); + if (r == R) + return FirstExt; + else + return static_array_impl::value(r); #endif } }; // End the recursion -template +template struct static_array_impl { MDSPAN_INLINE_FUNCTION - constexpr static T value(int) { - return FirstExt; - } - template - MDSPAN_INLINE_FUNCTION - constexpr static T get() { + constexpr static T value(int) { return FirstExt; } + template MDSPAN_INLINE_FUNCTION constexpr static T get() { return FirstExt; } }; // Don't start recursion if size 0 -template -struct static_array_impl<0, T> { +template struct static_array_impl<0, T> { MDSPAN_INLINE_FUNCTION - constexpr static T value(int) { - return T(); - } - template - MDSPAN_INLINE_FUNCTION - constexpr static T get() { + constexpr static T value(int) { return T(); } + template MDSPAN_INLINE_FUNCTION constexpr static T get() { return T(); } }; // Static array, provides get(), get(r) and operator[r] -template -struct static_array { +template struct static_array { private: using impl_t = static_array_impl<0, T, Values...>; + public: using value_type = T; @@ -98,241 +92,222 @@ struct static_array { constexpr T operator[](int r) const { return get(r); } MDSPAN_INLINE_FUNCTION constexpr static T get(int r) { return impl_t::value(r); } - template - MDSPAN_INLINE_FUNCTION - constexpr static T get() { return impl_t::template get(); } + template MDSPAN_INLINE_FUNCTION constexpr static T get() { + return impl_t::template get(); + } MDSPAN_INLINE_FUNCTION constexpr static size_t size() { return sizeof...(Values); } }; -// index_sequence_scan takes indicies and provides get(r) and get() to get the sum of the first r-1 values -template -struct index_sequence_scan_impl; +// index_sequence_scan takes indicies and provides get(r) and get() to get +// the sum of the first r-1 values +template struct index_sequence_scan_impl; -template +template struct index_sequence_scan_impl { MDSPAN_INLINE_FUNCTION constexpr static size_t get(size_t r) { - if(r>R) return FirstVal + index_sequence_scan_impl::get(r); - else return 0; + if (r > R) + return FirstVal + index_sequence_scan_impl::get(r); + else + return 0; + } + template MDSPAN_INLINE_FUNCTION constexpr static size_t get() { + return r > R ? FirstVal + index_sequence_scan_impl::get(r) + : 0; } - template - MDSPAN_INLINE_FUNCTION - constexpr static size_t get() { return r>R? FirstVal + index_sequence_scan_impl::get(r):0; } }; -template +template struct index_sequence_scan_impl { #if defined(__NVCC__) || defined(__NVCOMPILER) - // NVCC warns about pointless comparison with 0 for R==0 and r being const evaluatable and also 0 + // NVCC warns about pointless comparison with 0 for R==0 and r being const + // evaluatable and also 0 MDSPAN_INLINE_FUNCTION - constexpr static size_t get(size_t r) { return static_cast(R)>static_cast(r)?FirstVal:0; } + constexpr static size_t get(size_t r) { + return static_cast(R) > static_cast(r) ? FirstVal : 0; + } #else MDSPAN_INLINE_FUNCTION - constexpr static size_t get(size_t r) { return R>r?FirstVal:0; } + constexpr static size_t get(size_t r) { return R > r ? FirstVal : 0; } #endif - template - MDSPAN_INLINE_FUNCTION - constexpr static size_t get() { return R>r?FirstVal:0; } + template MDSPAN_INLINE_FUNCTION constexpr static size_t get() { + return R > r ? FirstVal : 0; + } }; -template<> -struct index_sequence_scan_impl<0> { +template <> struct index_sequence_scan_impl<0> { MDSPAN_INLINE_FUNCTION constexpr static size_t get(size_t) { return 0; } - template - MDSPAN_INLINE_FUNCTION - constexpr static size_t get() { return 0; } + template MDSPAN_INLINE_FUNCTION constexpr static size_t get() { + return 0; + } }; -// Need this to have fully empty class maybe_static_array with all entries static -// Rather specialize this small helper class on size 0, then the whole thing -template -struct possibly_empty_array { +// Need this to have fully empty class maybe_static_array with all entries +// static Rather specialize this small helper class on size 0, then the whole +// thing +template struct possibly_empty_array { T vals[N]; MDSPAN_INLINE_FUNCTION - constexpr T& operator[] (size_t r) { return vals[r]; } + constexpr T &operator[](size_t r) { return vals[r]; } MDSPAN_INLINE_FUNCTION - constexpr const T& operator[] (size_t r) const { return vals[r]; } + constexpr const T &operator[](size_t r) const { return vals[r]; } }; -template -struct possibly_empty_array { +template struct possibly_empty_array { MDSPAN_INLINE_FUNCTION - constexpr T operator[] (size_t) { return T(); } + constexpr T operator[](size_t) { return T(); } MDSPAN_INLINE_FUNCTION - constexpr const T operator[] (size_t) const { return T(); } + constexpr const T operator[](size_t) const { return T(); } }; - // maybe_static_array is an array which has a mix of static and dynamic values -template +template struct maybe_static_array { - private: - using static_vals_t = static_array; - constexpr static size_t m_size = sizeof...(Values); - constexpr static size_t m_size_dynamic = _MDSPAN_FOLD_PLUS_RIGHT((Values==dyn_tag), 0); +private: + using static_vals_t = static_array; + constexpr static size_t m_size = sizeof...(Values); + constexpr static size_t m_size_dynamic = + _MDSPAN_FOLD_PLUS_RIGHT((Values == dyn_tag), 0); - _MDSPAN_NO_UNIQUE_ADDRESS possibly_empty_array m_dyn_vals; - public: - using dyn_map_t = index_sequence_scan_impl<0, size_t(Values==dyn_tag)...>; + _MDSPAN_NO_UNIQUE_ADDRESS possibly_empty_array + m_dyn_vals; - using value_type = TDynamic; - using static_value_type = TStatic; - constexpr static static_value_type tag_value = dyn_tag; +public: + using dyn_map_t = index_sequence_scan_impl<0, size_t(Values == dyn_tag)...>; - constexpr maybe_static_array() = default; - - // constructors from dynamic_extentamic values only - MDSPAN_TEMPLATE_REQUIRES( - class ... DynVals, - /* requires */( - sizeof...(DynVals)==m_size_dynamic && m_size_dynamic>0 - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr maybe_static_array(DynVals ... vals): - m_dyn_vals{static_cast(vals)...} {} - - MDSPAN_TEMPLATE_REQUIRES( - class ... DynVals, - /* requires */( - (m_size_dynamic==0) && (sizeof...(DynVals)>0) - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr maybe_static_array(DynVals ...): - m_dyn_vals{} {} - - MDSPAN_TEMPLATE_REQUIRES( - class T, size_t N, - /* requires */( - N==m_size_dynamic && N>0 - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr maybe_static_array(const std::array& vals) { - for(size_t r=0; r(vals[r]); - } + using value_type = TDynamic; + using static_value_type = TStatic; + constexpr static static_value_type tag_value = dyn_tag; - MDSPAN_TEMPLATE_REQUIRES( - class T, size_t N, - /* requires */( - N==m_size_dynamic && N==0 - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr maybe_static_array(const std::array&) { - } + constexpr maybe_static_array() = default; + + // constructors from dynamic_extentamic values only + MDSPAN_TEMPLATE_REQUIRES(class... DynVals, + /* requires */ (sizeof...(DynVals) == + m_size_dynamic && + m_size_dynamic > 0)) + MDSPAN_INLINE_FUNCTION + constexpr maybe_static_array(DynVals... vals) + : m_dyn_vals{static_cast(vals)...} {} + + MDSPAN_TEMPLATE_REQUIRES(class... DynVals, + /* requires */ ((m_size_dynamic == 0) && + (sizeof...(DynVals) > 0))) + MDSPAN_INLINE_FUNCTION + constexpr maybe_static_array(DynVals...) : m_dyn_vals{} {} + + MDSPAN_TEMPLATE_REQUIRES(class T, size_t N, + /* requires */ (N == m_size_dynamic && N > 0)) + MDSPAN_INLINE_FUNCTION + constexpr maybe_static_array(const std::array &vals) { + for (size_t r = 0; r < N; r++) + m_dyn_vals[r] = static_cast(vals[r]); + } + + MDSPAN_TEMPLATE_REQUIRES(class T, size_t N, + /* requires */ (N == m_size_dynamic && N == 0)) + MDSPAN_INLINE_FUNCTION + constexpr maybe_static_array(const std::array &) {} #ifdef __cpp_lib_span - MDSPAN_TEMPLATE_REQUIRES( - class T, size_t N, - /* requires */( - N==m_size_dynamic - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr maybe_static_array(const std::span& vals) { - for(size_t r=0; r(vals[r]); - } + MDSPAN_TEMPLATE_REQUIRES(class T, size_t N, + /* requires */ (N == m_size_dynamic)) + MDSPAN_INLINE_FUNCTION + constexpr maybe_static_array(const std::span &vals) { + for (size_t r = 0; r < N; r++) + m_dyn_vals[r] = static_cast(vals[r]); + } #endif - // constructors from all values - MDSPAN_TEMPLATE_REQUIRES( - class ... DynVals, - /* requires */( - sizeof...(DynVals)!=m_size_dynamic && m_size_dynamic>0 - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr maybe_static_array(DynVals ... vals) { - static_assert((sizeof...(DynVals)==m_size), "Invalid number of values."); - TDynamic values[m_size]{static_cast(vals)...}; - for(size_t r=0; r 0)) + MDSPAN_INLINE_FUNCTION + constexpr maybe_static_array(DynVals... vals) { + static_assert((sizeof...(DynVals) == m_size), "Invalid number of values."); + TDynamic values[m_size]{static_cast(vals)...}; + for (size_t r = 0; r < m_size; r++) { + TStatic static_val = static_vals_t::get(r); + if (static_val == dynamic_extent) { + m_dyn_vals[dyn_map_t::get(r)] = values[r]; + } #ifdef _MDSPAN_DEBUG - else { - assert(values[r]==static_cast(static_val)); - } -#endif + else { + assert(values[r] == static_cast(static_val)); } +#endif } + } - MDSPAN_TEMPLATE_REQUIRES( + MDSPAN_TEMPLATE_REQUIRES( class T, size_t N, - /* requires */( - N!=m_size_dynamic && m_size_dynamic>0 - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr maybe_static_array(const std::array& vals) { - static_assert((N==m_size), "Invalid number of values."); + /* requires */ (N != m_size_dynamic && m_size_dynamic > 0)) + MDSPAN_INLINE_FUNCTION + constexpr maybe_static_array(const std::array &vals) { + static_assert((N == m_size), "Invalid number of values."); #ifdef _MDSPAN_DEBUG - assert(N==m_size); + assert(N == m_size); #endif - for(size_t r=0; r(vals[r]); - } + for (size_t r = 0; r < m_size; r++) { + TStatic static_val = static_vals_t::get(r); + if (static_val == dynamic_extent) { + m_dyn_vals[dyn_map_t::get(r)] = static_cast(vals[r]); + } #ifdef _MDSPAN_DEBUG - else { - assert(static_cast(vals[r])==static_cast(static_val)); - } -#endif + else { + assert(static_cast(vals[r]) == + static_cast(static_val)); } +#endif } + } #ifdef __cpp_lib_span - MDSPAN_TEMPLATE_REQUIRES( + MDSPAN_TEMPLATE_REQUIRES( class T, size_t N, - /* requires */( - N!=m_size_dynamic && m_size_dynamic>0 - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr maybe_static_array(const std::span& vals) { - static_assert((N==m_size) || (m_size==dynamic_extent)); + /* requires */ (N != m_size_dynamic && m_size_dynamic > 0)) + MDSPAN_INLINE_FUNCTION + constexpr maybe_static_array(const std::span &vals) { + static_assert((N == m_size) || (m_size == dynamic_extent)); #ifdef _MDSPAN_DEBUG - assert(N==m_size); + assert(N == m_size); #endif - for(size_t r=0; r(vals[r]); - } + for (size_t r = 0; r < m_size; r++) { + TStatic static_val = static_vals_t::get(r); + if (static_val == dynamic_extent) { + m_dyn_vals[dyn_map_t::get(r)] = static_cast(vals[r]); + } #ifdef _MDSPAN_DEBUG - else { - assert(static_cast(vals[r])==static_cast(static_val)); - } -#endif + else { + assert(static_cast(vals[r]) == + static_cast(static_val)); } +#endif } + } #endif - // access functions - MDSPAN_INLINE_FUNCTION - constexpr static TStatic static_value(int r) { return static_vals_t::get(r); } + // access functions + MDSPAN_INLINE_FUNCTION + constexpr static TStatic static_value(int r) { return static_vals_t::get(r); } - MDSPAN_INLINE_FUNCTION - constexpr TDynamic value(int r) const { - TStatic static_val = static_vals_t::get(r); - return static_val==dynamic_extent? - m_dyn_vals[dyn_map_t::get(r)] : static_cast(static_val); - } - MDSPAN_INLINE_FUNCTION - constexpr TDynamic operator[](int r) const { - return value(r); - } + MDSPAN_INLINE_FUNCTION + constexpr TDynamic value(int r) const { + TStatic static_val = static_vals_t::get(r); + return static_val == dynamic_extent ? m_dyn_vals[dyn_map_t::get(r)] + : static_cast(static_val); + } + MDSPAN_INLINE_FUNCTION + constexpr TDynamic operator[](int r) const { return value(r); } - // observers - MDSPAN_INLINE_FUNCTION - constexpr static size_t size() { return m_size; } - MDSPAN_INLINE_FUNCTION - constexpr static size_t size_dynamic() { return m_size_dynamic; } + // observers + MDSPAN_INLINE_FUNCTION + constexpr static size_t size() { return m_size; } + MDSPAN_INLINE_FUNCTION + constexpr static size_t size_dynamic() { return m_size_dynamic; } }; #if 0 @@ -356,22 +331,26 @@ struct maybe_static_array { }; #endif -}}} // namespace std::experimental::detail +} // namespace detail +} // namespace experimental +} // namespace std namespace std { namespace experimental { -template -class extents { +template class extents { public: using rank_type = size_t; using index_type = IndexType; using size_type = make_unsigned_t; + private: constexpr static rank_type m_rank = sizeof...(Extents); - constexpr static rank_type m_rank_dynamic = _MDSPAN_FOLD_PLUS_RIGHT((Extents==dynamic_extent), /* + ... + */ 0); + constexpr static rank_type m_rank_dynamic = + _MDSPAN_FOLD_PLUS_RIGHT((Extents == dynamic_extent), /* + ... + */ 0); - using vals_t = detail::maybe_static_array; + using vals_t = + detail::maybe_static_array; _MDSPAN_NO_UNIQUE_ADDRESS vals_t m_vals; public: @@ -381,9 +360,7 @@ class extents { constexpr static rank_type rank_dynamic() { return m_rank_dynamic; } MDSPAN_INLINE_FUNCTION - constexpr index_type extent(rank_type r) const { - return m_vals.value(r); - } + constexpr index_type extent(rank_type r) const { return m_vals.value(r); } MDSPAN_INLINE_FUNCTION constexpr static size_t static_extent(rank_type r) { return vals_t::static_value(r); @@ -393,126 +370,123 @@ class extents { constexpr extents() = default; MDSPAN_TEMPLATE_REQUIRES( - class ... OtherIndexTypes, - /* requires */( - _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, OtherIndexTypes, index_type) /* && ... */) && - _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_nothrow_constructible, index_type, OtherIndexTypes) /* && ... */) && - (sizeof...(OtherIndexTypes)==m_rank || sizeof...(OtherIndexTypes)==m_rank_dynamic) - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr extents(OtherIndexTypes ... dynvals):m_vals(static_cast(dynvals)...) {} + class... OtherIndexTypes, + /* requires */ ( + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, OtherIndexTypes, + index_type) /* && ... */) && + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_nothrow_constructible, index_type, + OtherIndexTypes) /* && ... */) && + (sizeof...(OtherIndexTypes) == m_rank || + sizeof...(OtherIndexTypes) == m_rank_dynamic))) + MDSPAN_INLINE_FUNCTION + constexpr extents(OtherIndexTypes... dynvals) + : m_vals(static_cast(dynvals)...) {} MDSPAN_TEMPLATE_REQUIRES( - class OtherIndexType, size_t N, - /* requires */( - // _MDSPAN_TRAIT(is_convertible, OtherIndexType, index_type) && - // _MDSPAN_TRAIT(is_nothrow_constructible, index_type, OtherIndexType) && - (N==m_rank || N==m_rank_dynamic) - ) - ) + class OtherIndexType, size_t N, + /* requires */ + ( + // _MDSPAN_TRAIT(is_convertible, OtherIndexType, index_type) && + // _MDSPAN_TRAIT(is_nothrow_constructible, index_type, + // OtherIndexType) && + (N == m_rank || N == m_rank_dynamic))) MDSPAN_INLINE_FUNCTION - constexpr extents(const array& exts):m_vals(std::move(exts)) {} + constexpr extents(const array &exts) + : m_vals(std::move(exts)) {} #ifdef __cpp_lib_span MDSPAN_TEMPLATE_REQUIRES( - class OtherIndexType, size_t N, - /* requires */( - _MDSPAN_TRAIT(is_convertible, OtherIndexType, index_type) && - _MDSPAN_TRAIT(is_nothrow_constructible, index_type, OtherIndexType) && - (N==m_rank || N==m_rank_dynamic) - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr extents(const span& exts):m_vals(std::move(exts)) {} + class OtherIndexType, size_t N, + /* requires */ + (_MDSPAN_TRAIT(is_convertible, OtherIndexType, index_type) && + _MDSPAN_TRAIT(is_nothrow_constructible, index_type, OtherIndexType) && + (N == m_rank || N == m_rank_dynamic))) + MDSPAN_INLINE_FUNCTION + constexpr extents(const span &exts) + : m_vals(std::move(exts)) {} #endif private: - // Function to construct extents storage from other extents. // With C++ 17 the first two variants could be collapsed using if constexpr // in which case you don't need all the requires clauses. // in C++ 14 mode that doesn't work due to infinite recursion MDSPAN_TEMPLATE_REQUIRES( - size_t DynCount, size_t R, class OtherExtents, class ... DynamicValues, - /* requires */( - (R < m_rank) && - (static_extent(R) == dynamic_extent) - ) - ) + size_t DynCount, size_t R, class OtherExtents, class... DynamicValues, + /* requires */ ((R < m_rank) && (static_extent(R) == dynamic_extent))) MDSPAN_INLINE_FUNCTION vals_t __construct_vals_from_extents(std::integral_constant, std::integral_constant, - const OtherExtents& exts, DynamicValues ... dynamic_values) { - return __construct_vals_from_extents(std::integral_constant(), - std::integral_constant(), - exts, dynamic_values ..., exts.extent(R)); + const OtherExtents &exts, + DynamicValues... dynamic_values) { + return __construct_vals_from_extents( + std::integral_constant(), + std::integral_constant(), exts, dynamic_values..., + exts.extent(R)); } MDSPAN_TEMPLATE_REQUIRES( - size_t DynCount, size_t R, class OtherExtents, class ... DynamicValues, - /* requires */( - (R < m_rank) && - (static_extent(R) != dynamic_extent) - ) - ) + size_t DynCount, size_t R, class OtherExtents, class... DynamicValues, + /* requires */ ((R < m_rank) && (static_extent(R) != dynamic_extent))) MDSPAN_INLINE_FUNCTION vals_t __construct_vals_from_extents(std::integral_constant, std::integral_constant, - const OtherExtents& exts, DynamicValues ... dynamic_values) { - return __construct_vals_from_extents(std::integral_constant(), - std::integral_constant(), - exts, dynamic_values ...); + const OtherExtents &exts, + DynamicValues... dynamic_values) { + return __construct_vals_from_extents( + std::integral_constant(), + std::integral_constant(), exts, dynamic_values...); } MDSPAN_TEMPLATE_REQUIRES( - size_t DynCount, size_t R, class OtherExtents, class ... DynamicValues, - /* requires */ ( - (R == m_rank) && - (DynCount == m_rank_dynamic) - ) - ) + size_t DynCount, size_t R, class OtherExtents, class... DynamicValues, + /* requires */ ((R == m_rank) && (DynCount == m_rank_dynamic))) MDSPAN_INLINE_FUNCTION vals_t __construct_vals_from_extents(std::integral_constant, std::integral_constant, - const OtherExtents&, DynamicValues ... dynamic_values) { + const OtherExtents &, + DynamicValues... dynamic_values) { return vals_t{static_cast(dynamic_values)...}; } public: MDSPAN_TEMPLATE_REQUIRES( - class OtherIndexType, size_t... OtherExtents, - /* requires */ ( - /* multi-stage check to protect from invalid pack expansion when sizes don't match? */ - decltype(detail::__check_compatible_extents( - std::integral_constant{}, - std::integer_sequence{}, - std::integer_sequence{} - ))::value - ) - ) - MDSPAN_INLINE_FUNCTION - MDSPAN_CONDITIONAL_EXPLICIT( - (((Extents != dynamic_extent) && (OtherExtents == dynamic_extent)) || ...) || - (std::numeric_limits::max() < std::numeric_limits::max())) - constexpr extents(const extents& other): - m_vals(__construct_vals_from_extents(std::integral_constant(), - std::integral_constant(), - other)) {} - - template - MDSPAN_INLINE_FUNCTION - friend constexpr bool operator==(const extents& lhs, - const extents& rhs) noexcept { + class OtherIndexType, size_t... OtherExtents, + /* requires */ + ( + /* multi-stage check to protect from invalid pack expansion when sizes + don't match? */ + decltype(detail::__check_compatible_extents( + std::integral_constant{}, + std::integer_sequence{}, + std::integer_sequence{}))::value)) + MDSPAN_INLINE_FUNCTION + MDSPAN_CONDITIONAL_EXPLICIT((((Extents != dynamic_extent) && + (OtherExtents == dynamic_extent)) || + ...) || + (std::numeric_limits::max() < + std::numeric_limits::max())) + constexpr extents(const extents &other) + : m_vals(__construct_vals_from_extents( + std::integral_constant(), + std::integral_constant(), other)) {} + + template + MDSPAN_INLINE_FUNCTION friend constexpr bool + operator==(const extents &lhs, + const extents &rhs) noexcept { bool value = true; - for(size_type r=0; r - MDSPAN_INLINE_FUNCTION - friend constexpr bool operator!=(extents const& lhs, extents const& rhs) noexcept { + template + MDSPAN_INLINE_FUNCTION friend constexpr bool + operator!=(extents const &lhs, + extents const &rhs) noexcept { return !(lhs == rhs); } #endif @@ -520,17 +494,23 @@ class extents { namespace detail { -template > +template > struct __make_dextents; template -struct __make_dextents> { - using type = typename __make_dextents>::type; +struct __make_dextents< + IndexType, Rank, ::std::experimental::extents> { + using type = typename __make_dextents< + IndexType, Rank - 1, + ::std::experimental::extents>::type; }; template -struct __make_dextents> { +struct __make_dextents< + IndexType, 0, ::std::experimental::extents> { using type = ::std::experimental::extents; }; @@ -542,19 +522,21 @@ using dextents = typename detail::__make_dextents::type; #if defined(_MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION) template extents(IndexTypes...) - -> extents; + -> extents; #endif namespace detail { -template -struct __is_extents : ::std::false_type {}; +template struct __is_extents : ::std::false_type {}; template -struct __is_extents<::std::experimental::extents> : ::std::true_type {}; +struct __is_extents<::std::experimental::extents> + : ::std::true_type {}; template static constexpr bool __is_extents_v = __is_extents::value; -} -}} // namespace std::experimental +} // namespace detail +} // namespace experimental +} // namespace std