ROL
Accessor_CPP20.hpp
Go to the documentation of this file.
1#include <concepts>
2#include <utility>
3
4// Helper to check if T is a specialization of Accessor (from previous answer)
5template <typename T>
6struct is_accessor_specialization_trait_cpp20 : std::false_type {};
7
8template <typename VectorType>
9struct is_accessor_specialization_trait_cpp20<Accessor<VectorType>> : std::true_type {};
10
11template <typename T>
13
14// Concept to check for full compliance
15template<typename Acc>
17 const Acc& accessor,
18 // Use placeholders that will be deduced based on Acc's member types
19 // If Acc::container_type doesn't exist, this part of the requires clause will fail.
20 typename Acc::container_type& mutable_container,
21 const typename Acc::container_type& const_container,
22 typename Acc::size_type index,
23 typename Acc::value_type val
24) {
25 // 1. Check for required member types
26 typename Acc::container_type;
27 typename Acc::value_type;
28 typename Acc::size_type;
29
30 // 2. Check for get_value member function
31 // - const-correct
32 // - takes const container_type&, size_type
33 // - returns value_type
34 { accessor.get_value(const_container, index) } -> std::same_as<typename Acc::value_type>;
35
36 // 3. Check for set_value member function
37 // - const-correct (the method itself is const)
38 // - takes container_type&, size_type, value_type
39 // - returns void
40 { accessor.set_value(mutable_container, index, val) } -> std::same_as<void>;
41};