@@ -1645,18 +1645,11 @@ class const_subarray : public array_types<T, D, ElementPtr, Layout> {
16451645
16461646 BOOST_MULTI_HD constexpr auto range (index_range irng) const & -> decltype(auto ) { return sliced (irng.front (), irng.front () + irng.size ()); } // cppcheck-suppress duplInheritedMember;
16471647
1648- [[deprecated("is_flattable will be a property of the layout soon")]]
1648+ // [[deprecated("is_flattable will be a property of the layout soon")]]
16491649 constexpr auto is_flattable () const -> bool {
16501650 return (this ->size () <= 1 ) || (this ->stride () == this ->layout ().sub ().nelems ());
16511651 }
16521652
1653- // friend constexpr auto flatted(const_subarray const& self) {return self.flatted();}
1654- constexpr auto flatted () const & {
1655- multi::layout_t <D - 1 > new_layout{this ->layout ().sub ()};
1656- new_layout.nelems () *= this ->size (); // TODO(correaa) : use immutable layout
1657- return const_subarray<T, D - 1 , ElementPtr>{new_layout, types::base_};
1658- }
1659-
16601653 private:
16611654 auto flattened_aux_ () const {
16621655 auto new_layout = this ->layout ().flatten (this ->base_ );
@@ -1666,6 +1659,13 @@ class const_subarray : public array_types<T, D, ElementPtr, Layout> {
16661659 public:
16671660 auto flattened () const & { return flattened_aux_ ().as_const (); }
16681661
1662+ constexpr auto flatted () const & {
1663+ assert (is_flattable ());
1664+ multi::layout_t <D - 1 > new_layout{this ->layout ().sub ()};
1665+ new_layout.nelems () *= this ->size (); // TODO(correaa) : use immutable layout
1666+ return const_subarray<T, D - 1 , ElementPtr>{new_layout, this ->base_ };
1667+ }
1668+
16691669 private:
16701670 constexpr auto broadcasted () const & { // NOLINT(readability-identifier-naming) TODO(correaa) remove?
16711671 // TODO(correaa) introduce a broadcasted_layout?
@@ -2546,14 +2546,23 @@ class subarray : public const_subarray<T, D, ElementPtr, Layout> {
25462546 // cppcheck-suppress duplInheritedMember ; to overwrite
25472547 BOOST_MULTI_HD constexpr auto partitioned (size_type size) && -> subarray<T, D + 1, typename subarray::element_ptr> { return this ->partitioned_aux_ (size); }
25482548
2549- using const_subarray<T, D, ElementPtr, Layout>::flatted;
2549+ // using const_subarray<T, D, ElementPtr, Layout>::flatted;
2550+ constexpr auto flatted () const & {
2551+ assert (this ->is_flattable ());
2552+ multi::layout_t <D - 1 > new_layout{this ->layout ().sub ()};
2553+ new_layout.nelems () *= this ->size (); // TODO(correaa) : use immutable layout
2554+ return const_subarray<T, D - 1 , ElementPtr>{new_layout, this ->base_ };
2555+ }
2556+
25502557 // cppcheck-suppress duplInheritedMember ; to overwrite
25512558 constexpr auto flatted () & {
2559+ // assert(this->is_flattable());
25522560 // assert(is_flattable() && "flatted doesn't work for all layouts!");
25532561 multi::layout_t <D - 1 > new_layout{this ->layout ().sub ()};
25542562 new_layout.nelems () *= this ->size (); // TODO(correaa) : use immutable layout
25552563 return subarray<T, D - 1 , ElementPtr>(new_layout, this ->base_ );
25562564 }
2565+
25572566 constexpr auto flatted () && { return this ->flatted (); } // cppcheck-suppress duplInheritedMember ; to override
25582567
25592568 using const_subarray<T, D, ElementPtr, Layout>::reinterpret_array_cast;
@@ -3823,6 +3832,25 @@ class array_ref : public subarray<T, D, ElementPtr, Layout> {
38233832 friend constexpr auto sizes (array_ref const & self) noexcept /* -> typename array_ref::sizes_type*/ { return self.sizes (); } // needed by nvcc
38243833 friend constexpr auto size (array_ref const & self) noexcept /* -> typename array_ref::size_type*/ { return self.size (); } // needed by nvcc
38253834
3835+ // using const_subarray<T, D, ElementPtr, Layout>::flatted;
3836+ constexpr auto flatted () const & {
3837+ assert (this ->is_flattable ());
3838+ multi::layout_t <D - 1 > new_layout{this ->layout ().sub ()};
3839+ new_layout.nelems () *= this ->size (); // TODO(correaa) : use immutable layout
3840+ return const_subarray<T, D - 1 , ElementPtr>{new_layout, this ->base_ };
3841+ }
3842+
3843+ // cppcheck-suppress duplInheritedMember ; to overwrite
3844+ constexpr auto flatted () & {
3845+ assert (this ->is_flattable ());
3846+ // assert(is_flattable() && "flatted doesn't work for all layouts!");
3847+ multi::layout_t <D - 1 > new_layout{this ->layout ().sub ()};
3848+ new_layout.nelems () *= this ->size (); // TODO(correaa) : use immutable layout
3849+ return subarray<T, D - 1 , ElementPtr>(new_layout, this ->base_ );
3850+ }
3851+
3852+ constexpr auto flatted () && { return this ->flatted (); } // cppcheck-suppress duplInheritedMember ; to override
3853+
38263854#if defined(BOOST_MULTI_HAS_SPAN) && !defined(__NVCC__)
38273855 // using element_type = typename array_ref::element;
38283856 template <class U = typename array_ref::element, std::enable_if_t <std::is_convertible_v<typename array_ref::element_const_ptr, U const *> && (D == 1 ), int > = 0 > // NOLINT(modernize-use-constraints) for C++20
0 commit comments