1818// forward declarations
1919
2020namespace edm {
21-
2221 namespace impl {
2322
24- // check if a type T has a subscript operator T[N]
25- template <typename , typename = void >
26- struct has_subscript_operator : std::false_type {};
27-
28- template <typename T>
29- struct has_subscript_operator <T, std::void_t <decltype (std::declval<T&>()[0 ])>> : std::true_type {};
30-
3123 template <typename T>
32- constexpr auto has_subscript_operator_v = has_subscript_operator<T>::value ;
24+ concept ArrayAddressable = requires (T& a) { a[ 0 ]; } or std::is_array_v<T> ;
3325
3426 // for a type T, return the type of the return value of the subscript operator T[N]
3527 template <typename T, typename = void , typename = void >
@@ -48,7 +40,11 @@ namespace edm {
4840
4941 // for non-array types that implement the subscript operator[], a complete type is needed
5042 template <typename T>
51- struct subscript_type <T, std::enable_if_t <not std::is_array_v<T>>, std::enable_if_t <has_subscript_operator_v<T>>> {
43+ requires requires {
44+ requires not std::is_array_v<T>;
45+ requires ArrayAddressable<T>;
46+ }
47+ struct subscript_type <T> {
5248 using type = typename std::remove_reference<decltype (std::declval<T&>()[0 ])>::type;
5349 };
5450
@@ -57,21 +53,21 @@ namespace edm {
5753
5854 } // namespace impl
5955
60- template <typename T>
56+ template <impl::ArrayAddressable T>
6157 class propagate_const_array ;
6258
6359 template <typename T>
6460 constexpr std::decay_t <T>& get_underlying (propagate_const_array<T>&);
6561 template <typename T>
6662 constexpr std::decay_t <T> const & get_underlying (propagate_const_array<T> const &);
6763
68- template <typename T>
64+ template <impl::ArrayAddressable T>
6965 class propagate_const_array {
7066 public:
7167 friend constexpr std::decay_t <T>& get_underlying<T>(propagate_const_array<T>&);
7268 friend constexpr std::decay_t <T> const & get_underlying<T>(propagate_const_array<T> const &);
7369
74- template <typename U>
70+ template <impl::ArrayAddressable U>
7571 friend class propagate_const_array ;
7672
7773 using element_type = typename impl::subscript_type_t <T>;
0 commit comments