20 #ifndef CS_CRYPTO_UTIL_CRYPTO_TRAITS_H
21 #define CS_CRYPTO_UTIL_CRYPTO_TRAITS_H
26 namespace cs_crypto::traits {
29 struct always_false :
public std::false_type {
38 using identity_t =
typename identity<T>::type;
41 using begin_t =
decltype(std::begin(std::declval<T>()));
44 using end_t =
decltype(std::end(std::declval<T>()));
46 template <
typename T,
typename U>
47 using equality_comparable =
decltype(std::declval<T &>() == std::declval<U &>());
49 template <
typename T,
typename =
void>
56 struct is_iterable<T, std::void_t<begin_t<T>, end_t<T>, equality_comparable<begin_t<T>, end_t<T>>>>
57 :
public std::true_type
62 inline constexpr bool is_iterable_v = is_iterable<T>::value;
65 struct remove_optional {
70 struct remove_optional<std::optional<T>>
71 :
public remove_optional<T>
76 using remove_optional_t =
typename remove_optional<T>::type;
80 static_assert(std::is_enum_v<
decltype(A)>,
"Type trait enum_to_type only valid for enums");
81 constexpr static const auto value = A;
85 [[maybe_unused]]
inline constexpr bool is_uniquely_represented_byte_v =
86 std::is_trivially_copyable_v<T> &&
87 std::has_unique_object_representations<T>::value &&
sizeof(T) == 1;