25 #ifndef CRYPTO3_TYPE_TRAITS_HPP
26 #define CRYPTO3_TYPE_TRAITS_HPP
28 #define GENERATE_HAS_MEMBER_TYPE(Type) \
31 class HasMemberType_##Type { \
33 using Yes = char[2]; \
39 struct Derived : T, Fallback { }; \
42 static No &test(typename U::Type *); \
43 template<typename U> \
44 static Yes &test(U *); \
47 static constexpr bool RESULT = sizeof(test<Derived>(nullptr)) == sizeof(Yes); \
51 struct has_##Type : public std::integral_constant<bool, HasMemberType_##Type<T>::RESULT> { };
53 #define GENERATE_HAS_MEMBER(member) \
56 class HasMember_##member { \
58 using Yes = char[2]; \
64 struct Derived : T, Fallback { }; \
67 static No &test(decltype(U::member) *); \
68 template<typename U> \
69 static Yes &test(U *); \
72 static constexpr bool RESULT = sizeof(test<Derived>(nullptr)) == sizeof(Yes); \
76 struct has_##member : public std::integral_constant<bool, HasMember_##member<T>::RESULT> { };
78 #define GENERATE_HAS_MEMBER_FUNCTION(Function, ...) \
80 template<typename T> \
81 struct has_##Function { \
83 void Function(##__VA_ARGS__); \
86 struct Derived : Fallback { }; \
88 template<typename C, C> \
91 template<typename C> \
92 static char (&f(ChT<void (Fallback::*)(##__VA_ARGS__), &C::Function> *))[1]; \
94 template<typename C> \
95 static char (&f(...))[2]; \
97 static bool const value = sizeof(f<Derived>(0)) == 2; \
100 #define GENERATE_HAS_MEMBER_CONST_FUNCTION(Function, ...) \
102 template<typename T> \
103 struct has_##Function { \
105 void Function(##__VA_ARGS__) const; \
108 struct Derived : Fallback { }; \
110 template<typename C, C> \
113 template<typename C> \
114 static char (&f(ChT<void (Fallback::*)(##__VA_ARGS__) const, &C::Function> *))[1]; \
116 template<typename C> \
117 static char (&f(...))[2]; \
119 static bool const value = sizeof(f<Derived>(0)) == 2; \
122 #define GENERATE_HAS_MEMBER_RETURN_FUNCTION(Function, ReturnType, ...) \
124 template<typename T> \
125 struct has_##Function { \
127 typedef void ReturnType; \
129 typedef typename std::conditional<has_##ReturnType<T>::value, T, Dummy>::type TType; \
130 typedef typename TType::ReturnType type; \
133 type Function(##__VA_ARGS__); \
136 struct Derived : TType, Fallback { }; \
138 template<typename C, C> \
141 template<typename C> \
142 static char (&f(ChT<type (Fallback::*)(##__VA_ARGS__), &C::Function> *))[1]; \
144 template<typename C> \
145 static char (&f(...))[2]; \
147 static bool const value = sizeof(f<Derived>(0)) == 2; \
150 #define GENERATE_HAS_MEMBER_CONST_RETURN_FUNCTION(Function, ReturnType, ...) \
152 template<typename T> \
153 struct has_##Function { \
155 typedef void ReturnType; \
157 typedef typename std::conditional<has_##ReturnType<T>::value, T, Dummy>::type TType; \
158 typedef typename TType::ReturnType type; \
161 type Function(##__VA_ARGS__) const; \
164 struct Derived : TType, Fallback { }; \
166 template<typename C, C> \
169 template<typename C> \
170 static char (&f(ChT<type (Fallback::*)(##__VA_ARGS__) const, &C::Function> *))[1]; \
172 template<typename C> \
173 static char (&f(...))[2]; \
175 static bool const value = sizeof(f<Derived>(0)) == 2; \
226 template<typename U, typename = typename std::iterator_traits<U>::difference_type,
227 typename =
typename std::iterator_traits<U>::pointer,
228 typename =
typename std::iterator_traits<U>::reference,
229 typename =
typename std::iterator_traits<U>::value_type,
230 typename =
typename std::iterator_traits<U>::iterator_category>
233 constexpr
static bool value = std::is_same<decltype(test(std::declval<T>())),
long>
::value;
236 template<
typename Range>
238 static const bool value = has_begin<Range>::value && has_end<Range>::value;
241 template<
typename Container>
242 struct is_container {
243 static const bool value =
244 has_const_iterator<Container>::value && has_begin<Container>::value && has_end<Container>::value;
249 static const bool value = has_encoded_value_type<T>::value && has_encoded_value_bits<T>::value &&
250 has_decoded_value_type<T>::value && has_decoded_value_bits<T>::value &&
251 has_encoded_block_type<T>::value && has_encoded_block_bits<T>::value &&
252 has_decoded_block_type<T>::value && has_decoded_block_bits<T>::value &&
253 has_encode<T>::value && has_decode<T>::value;
259 static const bool value = has_word_type<T>::value && has_word_bits<T>::value &&
260 has_block_type<T>::value && has_block_bits<T>::value &&
261 has_key_type<T>::value && has_key_bits<T>::value && has_rounds<T>::value &&
262 has_encrypt<T>::value && has_decrypt<T>::value;
275 static one test_construction_type(
typename C::construction::type *);
278 static two test_construction_type(...);
281 static one test_construction_params(
typename C::construction::params_type *);
284 static two test_construction_params(...);
287 static const bool value = has_digest_type<T>::value && has_digest_bits<T>::value &&
288 sizeof(test_construction_type<T>(0)) ==
sizeof(one) &&
289 sizeof(test_construction_params<T>(0)) ==
sizeof(one);
295 static const bool value = has_digest_type<T>::value && has_digest_bits<T>::value &&
296 has_block_type<T>::value && has_block_bits<T>::value &&
297 has_key_type<T>::value && has_key_bits<T>::value;
303 static const bool value = has_digest_type<T>::value && has_digest_bits<T>::value &&
304 has_key_type<T>::value && has_max_key_bits<T>::value &&
305 has_min_key_bits<T>::value;
311 static const bool value = has_generate<T>::value && has_check<T>::value;
#define GENERATE_HAS_MEMBER_CONST_RETURN_FUNCTION(Function, ReturnType,...)
Definition: block/include/nil/crypto3/detail/type_traits.hpp:150
#define GENERATE_HAS_MEMBER_RETURN_FUNCTION(Function, ReturnType,...)
Definition: block/include/nil/crypto3/detail/type_traits.hpp:122
#define GENERATE_HAS_MEMBER_CONST_FUNCTION(Function,...)
Definition: block/include/nil/crypto3/detail/type_traits.hpp:100
#define GENERATE_HAS_MEMBER_TYPE(Type)
Definition: block/include/nil/crypto3/detail/type_traits.hpp:28
#define GENERATE_HAS_MEMBER(member)
Definition: block/include/nil/crypto3/detail/type_traits.hpp:53
#define GENERATE_HAS_MEMBER_FUNCTION(Function,...)
Definition: block/include/nil/crypto3/detail/type_traits.hpp:78
OutputIterator encrypt(InputIterator first, InputIterator last, KeyInputIterator key_first, KeyInputIterator key_last, OutputIterator out)
Definition: block/include/nil/crypto3/block/algorithm/encrypt.hpp:66
OutputIterator decrypt(InputIterator first, InputIterator last, KeyInputIterator key_first, KeyInputIterator key_last, OutputIterator out)
Definition: block/include/nil/crypto3/block/algorithm/decrypt.hpp:66
std::enable_if< detail::is_iterator< OutputIterator >::value, OutputIterator >::type encode(InputIterator first, InputIterator last, OutputIterator out)
Encodes the elements with particular codec defined with Encoder in the range, defined by [first,...
Definition: codec/include/nil/crypto3/codec/algorithm/encode.hpp:57
std::enable_if< detail::is_iterator< OutputIterator >::value, OutputIterator >::type decode(InputIterator first, InputIterator last, OutputIterator out)
Decodes the elements with particular codec defined with Decoder in the range, defined by [first,...
Definition: decode.hpp:57
constexpr decltype(auto) generate(F &&f)
generates a matrix as a function of its indices
Definition: matrix/utility.hpp:84
OutputIterator check(InputIterator first, InputIterator last, OutputIterator out)
Definition: check.hpp:52
Definition: algebra/include/nil/crypto3/detail/type_traits.hpp:125
T type
Definition: block/include/nil/crypto3/detail/type_traits.hpp:263
static const bool value
Definition: algebra/include/nil/crypto3/detail/type_traits.hpp:126
static const bool value
Definition: algebra/include/nil/crypto3/detail/type_traits.hpp:111
T type
Definition: block/include/nil/crypto3/detail/type_traits.hpp:254
static const bool value
Definition: algebra/include/nil/crypto3/detail/type_traits.hpp:100
Definition: algebra/include/nil/crypto3/detail/type_traits.hpp:137
T type
Definition: block/include/nil/crypto3/detail/type_traits.hpp:290
static const bool value
Definition: algebra/include/nil/crypto3/detail/type_traits.hpp:157
constexpr static bool value
Definition: algebra/include/nil/crypto3/detail/type_traits.hpp:88
Definition: algebra/include/nil/crypto3/detail/type_traits.hpp:174
static const bool value
Definition: algebra/include/nil/crypto3/detail/type_traits.hpp:175
T type
Definition: block/include/nil/crypto3/detail/type_traits.hpp:306
Definition: algebra/include/nil/crypto3/detail/type_traits.hpp:165
T type
Definition: block/include/nil/crypto3/detail/type_traits.hpp:298
static const bool value
Definition: algebra/include/nil/crypto3/detail/type_traits.hpp:166
Definition: algebra/include/nil/crypto3/detail/type_traits.hpp:184
static const bool value
Definition: algebra/include/nil/crypto3/detail/type_traits.hpp:185
T type
Definition: block/include/nil/crypto3/detail/type_traits.hpp:312
Definition: algebra/include/nil/crypto3/detail/type_traits.hpp:92
static const bool value
Definition: algebra/include/nil/crypto3/detail/type_traits.hpp:93