diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst index 2a34aa4fe55cc..1bd6e61194675 100644 --- a/libcxx/docs/FeatureTestMacroTable.rst +++ b/libcxx/docs/FeatureTestMacroTable.rst @@ -446,6 +446,8 @@ Status ---------------------------------------------------------- ----------------- ``__cpp_lib_linalg`` *unimplemented* ---------------------------------------------------------- ----------------- + ``__cpp_lib_mdspan`` ``202406L`` + ---------------------------------------------------------- ----------------- ``__cpp_lib_optional_range_support`` *unimplemented* ---------------------------------------------------------- ----------------- ``__cpp_lib_out_ptr`` *unimplemented* diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst index d30021b7eb234..513a211a08e81 100644 --- a/libcxx/docs/ReleaseNotes/19.rst +++ b/libcxx/docs/ReleaseNotes/19.rst @@ -53,6 +53,7 @@ Implemented Papers - P2713R1 - Escaping improvements in ``std::format`` - P2231R1 - Missing ``constexpr`` in ``std::optional`` and ``std::variant`` - P0019R8 - ``std::atomic_ref`` +- P2389R2 - Alias template ``dims`` for the ``extents`` of ``mdspan`` Improvements and New Features ----------------------------- diff --git a/libcxx/docs/Status/Cxx2cPapers.csv b/libcxx/docs/Status/Cxx2cPapers.csv index 48d45e24a05b2..ee2ce833e1383 100644 --- a/libcxx/docs/Status/Cxx2cPapers.csv +++ b/libcxx/docs/Status/Cxx2cPapers.csv @@ -65,7 +65,7 @@ "","","","","","","" "`P2747R2 `__","CWG","``constexpr`` placement new","St. Louis June 2024","","","" "`P2997R1 `__","LWG","Removing the common reference requirement from the indirectly invocable concepts","St. Louis June 2024","","","" -"`P2389R2 `__","LWG","``dextents`` Index Type Parameter","St. Louis June 2024","","","" +"`P2389R2 `__","LWG","``dextents`` Index Type Parameter","St. Louis June 2024","|Complete|","19.0","" "`P3168R2 `__","LWG","Give ``std::optional`` Range Support","St. Louis June 2024","","","|ranges|" "`P3217R0 `__","LWG","Adjoints to 'Enabling list-initialization for algorithms': find_last","St. Louis June 2024","","","" "`P2985R0 `__","LWG","A type trait for detecting virtual base classes","St. Louis June 2024","","","" diff --git a/libcxx/include/__mdspan/extents.h b/libcxx/include/__mdspan/extents.h index fea0decd8c6af..95082ef3d11ac 100644 --- a/libcxx/include/__mdspan/extents.h +++ b/libcxx/include/__mdspan/extents.h @@ -454,6 +454,12 @@ struct __make_dextents< _IndexType, 0, extents<_IndexType, _ExtentsPack...>> { template using dextents = typename __mdspan_detail::__make_dextents<_IndexType, _Rank>::type; +# if _LIBCPP_STD_VER >= 26 +// [mdspan.extents.dims], alias template `dims` +template +using dims = dextents<_IndexType, _Rank>; +# endif + // Deduction guide for extents # if _LIBCPP_STD_VER >= 26 template diff --git a/libcxx/include/mdspan b/libcxx/include/mdspan index 8d443f4acd1dd..aa7ba278b1aa0 100644 --- a/libcxx/include/mdspan +++ b/libcxx/include/mdspan @@ -20,6 +20,10 @@ namespace std { template using dextents = see below; + // [mdspan.extents.dims], alias template dims + template + using dims = see below; // since C++26 + // [mdspan.layout], layout mapping struct layout_left; struct layout_right; diff --git a/libcxx/include/version b/libcxx/include/version index 21231a4d4b0fc..7fa4f1c1e0fb8 100644 --- a/libcxx/include/version +++ b/libcxx/include/version @@ -159,7 +159,8 @@ __cpp_lib_make_unique 201304L __cpp_lib_map_try_emplace 201411L __cpp_lib_math_constants 201907L __cpp_lib_math_special_functions 201603L -__cpp_lib_mdspan 202207L +__cpp_lib_mdspan 202406L + 202207L // C++23 __cpp_lib_memory_resource 201603L __cpp_lib_move_iterator_concept 202207L __cpp_lib_move_only_function 202110L @@ -530,6 +531,8 @@ __cpp_lib_void_t 201411L // # define __cpp_lib_is_virtual_base_of 202406L // # define __cpp_lib_is_within_lifetime 202306L // # define __cpp_lib_linalg 202311L +# undef __cpp_lib_mdspan +# define __cpp_lib_mdspan 202406L // # define __cpp_lib_optional_range_support 202406L # undef __cpp_lib_out_ptr // # define __cpp_lib_out_ptr 202311L diff --git a/libcxx/test/std/containers/views/mdspan/extents/dims.pass.cpp b/libcxx/test/std/containers/views/mdspan/extents/dims.pass.cpp new file mode 100644 index 0000000000000..e74bc0e66fca1 --- /dev/null +++ b/libcxx/test/std/containers/views/mdspan/extents/dims.pass.cpp @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23 + +// + +// template +// using dims = see below; +// +// Result: A type E that is a specialization of extents such that +// E::rank() == Rank && E::rank() == E::rank_dynamic() is true, +// and E::index_type denotes IndexType. + +#include +#include + +#include "test_macros.h" + +template +void test_alias_template_dims() { + constexpr size_t D = std::dynamic_extent; + ASSERT_SAME_TYPE(std::dims<0, IndexType>, std::extents); + ASSERT_SAME_TYPE(std::dims<1, IndexType>, std::extents); + ASSERT_SAME_TYPE(std::dims<2, IndexType>, std::extents); + ASSERT_SAME_TYPE(std::dims<3, IndexType>, std::extents); + ASSERT_SAME_TYPE(std::dims<9, IndexType>, std::extents); +} + +template <> +void test_alias_template_dims() { + constexpr size_t D = std::dynamic_extent; + ASSERT_SAME_TYPE(std::dims<0>, std::extents); + ASSERT_SAME_TYPE(std::dims<1>, std::extents); + ASSERT_SAME_TYPE(std::dims<2>, std::extents); + ASSERT_SAME_TYPE(std::dims<3>, std::extents); + ASSERT_SAME_TYPE(std::dims<9>, std::extents); +} + +int main(int, char**) { + test_alias_template_dims(); + test_alias_template_dims(); + test_alias_template_dims(); + return 0; +} diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/mdspan.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/mdspan.version.compile.pass.cpp index 4ef3382306421..64d1c99b223f4 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/mdspan.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/mdspan.version.compile.pass.cpp @@ -18,6 +18,7 @@ /* Constant Value __cpp_lib_freestanding_mdspan 202311L [C++26] __cpp_lib_mdspan 202207L [C++23] + 202406L [C++26] __cpp_lib_submdspan 202306L [C++26] */ @@ -115,8 +116,8 @@ # ifndef __cpp_lib_mdspan # error "__cpp_lib_mdspan should be defined in c++26" # endif -# if __cpp_lib_mdspan != 202207L -# error "__cpp_lib_mdspan should have the value 202207L in c++26" +# if __cpp_lib_mdspan != 202406L +# error "__cpp_lib_mdspan should have the value 202406L in c++26" # endif # if !defined(_LIBCPP_VERSION) diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp index c0ffd78ebe3b1..4bc7362fda3f3 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp @@ -147,6 +147,7 @@ __cpp_lib_math_constants 201907L [C++20] __cpp_lib_math_special_functions 201603L [C++17] __cpp_lib_mdspan 202207L [C++23] + 202406L [C++26] __cpp_lib_memory_resource 201603L [C++17] __cpp_lib_modules 202207L [C++23] __cpp_lib_move_iterator_concept 202207L [C++20] @@ -7307,8 +7308,8 @@ # ifndef __cpp_lib_mdspan # error "__cpp_lib_mdspan should be defined in c++26" # endif -# if __cpp_lib_mdspan != 202207L -# error "__cpp_lib_mdspan should have the value 202207L in c++26" +# if __cpp_lib_mdspan != 202406L +# error "__cpp_lib_mdspan should have the value 202406L in c++26" # endif # if !defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_PMR diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index e92b6613b11a8..7d18615a1179b 100755 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -872,7 +872,7 @@ def add_version_header(tc): "name": "__cpp_lib_mdspan", "values": { "c++23": 202207, - # "c++26": 202406, # P2389R2 dextents Index Type Parameter + "c++26": 202406, # P2389R2 dextents Index Type Parameter }, "headers": ["mdspan"], },