Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
mdspan_concepts.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
19
20#include <experimental/mdspan>
21
22namespace shambase {
23
24 namespace details {
25
26 template<class T>
27 struct _helper_is_mdspan : std::false_type {};
28
29 template<class T, class Extents, class Layout, class Accessor>
30 struct _helper_is_mdspan<std::mdspan<T, Extents, Layout, Accessor>> : std::true_type {};
31
32 } // namespace details
33
34 template<class T>
35 inline constexpr bool is_mdspan_v = details::_helper_is_mdspan<std::remove_cvref_t<T>>::value;
36
37 template<class T>
38 using mdspan_value_t = typename std::remove_cvref_t<T>::value_type;
39
40 template<class T>
41 concept is_mdspan = is_mdspan_v<T>;
42
43 template<class T, std::size_t Rank>
44 concept is_mdspan_rank = is_mdspan<T> && (std::remove_cvref_t<T>::rank() == Rank);
45
46 template<class A, class B>
47 concept same_mdspan_value_t = std::same_as<mdspan_value_t<A>, mdspan_value_t<B>>;
48
49} // namespace shambase
namespace for basic c++ utilities