diff --git a/docs/libcudacxx/standard_api.rst b/docs/libcudacxx/standard_api.rst index 0729df55406..cb01d478702 100644 --- a/docs/libcudacxx/standard_api.rst +++ b/docs/libcudacxx/standard_api.rst @@ -101,5 +101,7 @@ Feature availability: - C++23 ```` is available in C++17. - - mdspan is feature complete in C++17 onwards. - - mdspan on msvc is only supported in C++20 and onwards. + - ``mdspan`` is feature complete in C++17 onwards. + - ``mdspan`` on msvc is only supported in C++20 and onwards. + +- C++26 ``std::dims`` is available in C++17. diff --git a/docs/libcudacxx/standard_api/container_library/mdspan.rst b/docs/libcudacxx/standard_api/container_library/mdspan.rst index 664a60eb48e..72174d13624 100644 --- a/docs/libcudacxx/standard_api/container_library/mdspan.rst +++ b/docs/libcudacxx/standard_api/container_library/mdspan.rst @@ -7,6 +7,7 @@ Extensions ---------- - All features of ```` are made available in C++17 onwards +- C++26 ``std::dims`` is made available in C++17 onwards Restrictions ------------ diff --git a/libcudacxx/include/cuda/std/__mdspan/extents.h b/libcudacxx/include/cuda/std/__mdspan/extents.h index d0bdfd016f6..0acb6579d7d 100644 --- a/libcudacxx/include/cuda/std/__mdspan/extents.h +++ b/libcudacxx/include/cuda/std/__mdspan/extents.h @@ -523,6 +523,9 @@ struct __make_dextents<_IndexType, 0, _CUDA_VSTD::extents<_IndexType, _ExtentsPa template using dextents = typename __detail::__make_dextents<_IndexType, _Rank>::type; +template +using dims = dextents<_IndexType, _Rank>; + # if defined(__MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION) template _CCCL_HOST_DEVICE extents(_IndexTypes...) diff --git a/libcudacxx/test/libcudacxx/std/containers/views/mdspan/mdspan.extents.dims/compare.pass.cpp b/libcudacxx/test/libcudacxx/std/containers/views/mdspan/mdspan.extents.dims/compare.pass.cpp new file mode 100644 index 00000000000..ec2e8c6d725 --- /dev/null +++ b/libcudacxx/test/libcudacxx/std/containers/views/mdspan/mdspan.extents.dims/compare.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++11 +// UNSUPPORTED: msvc && c++14, msvc && c++17 + +#include +#include + +int main(int, char**) +{ + { + using index_t = size_t; + + cuda::std::dextents e0{1, 2, 3}; + cuda::std::dims<3> e1{1, 2, 3}; + + static_assert(cuda::std::is_same::value, ""); + assert(e0 == e1); + } + + return 0; +}