21 struct is_string : std::bool_constant<std::is_same_v<T, std::string> || std::is_same_v<T, std::wstring>> {};
23 template<
typename T,
typename _ =
void>
24 struct is_container : std::false_type {};
27 struct is_container<T, std::void_t<decltype(std::declval<T>().begin()), decltype(std::declval<T>().end()), typename T::value_type>>
28 : std::bool_constant<!is_string<std::decay_t<T>>::value> {};
30 template<
typename T,
typename _ =
void>
31 struct is_optional : std::false_type {};
34 struct is_optional<T, std::void_t<typename T::value_type>>
35 : std::is_same<T, std::optional<typename T::value_type>> {};
37 template<
typename T,
typename _ =
void>
38 struct is_pair : std::false_type {};
41 struct is_pair<T, std::void_t<
42 decltype(std::declval<T>().first),
43 decltype(std::declval<T>().second)
44 >> : std::true_type {};
47 struct is_variant : std::false_type {};
49 template<
typename... Ts>
50 struct is_variant<std::variant<Ts...>> : std::true_type {};
52 template<
typename VariantT,
typename U, std::size_t... I>
53 constexpr bool variant_has_type_impl(std::index_sequence<I...>)
noexcept {
54 return ((std::is_same_v<std::remove_cvref_t<U>, std::remove_cvref_t<std::variant_alternative_t<I, VariantT>>>) || ...);
57 template<
typename VariantT,
typename U>
58 struct variant_has_type : std::bool_constant<
59 variant_has_type_impl<VariantT, U>(std::make_index_sequence<std::variant_size_v<VariantT>>())
82 concept String = is_string<T>::value;
122 concept Pair = is_pair<T>::value;
148 concept Enum = std::is_enum_v<std::remove_cv_t<E>>;
278 concept Variant = is_variant<std::remove_cvref_t<T>>::value;
291 template<
typename T,
typename U>
371 template<
typename F,
typename... Args>
372 concept Callable = std::is_invocable_v<F, Args...>;
386 template<
typename T,
typename U>
387 concept SameAs = std::is_same_v<std::remove_cvref_t<T>, std::remove_cvref_t<U>>;
401 template<
typename From,
typename To>
Concept to check if a type is arithmetic.
Definition type_traits.hxx:213
Concept to check if a type is callable.
Definition type_traits.hxx:372
Concept to check if a type is a class or struct.
Definition type_traits.hxx:265
Concept to check if a type is const-qualified.
Definition type_traits.hxx:252
Concept to check if a type is a container (excluding strings).
Definition type_traits.hxx:96
Concept to check if one type is convertible to another.
Definition type_traits.hxx:402
Concept to check if a type is copy constructible.
Definition type_traits.hxx:344
Concept to check if a type is default constructible.
Definition type_traits.hxx:331
Concept to check if a type is an enumeration.
Definition type_traits.hxx:148
Concept to check if a type is a floating-point type.
Definition type_traits.hxx:200
Concept to check if a type is an integral type.
Definition type_traits.hxx:187
Concept to check if a type is move constructible.
Definition type_traits.hxx:357
Concept to check if a type is an optional.
Definition type_traits.hxx:109
Concept to check if a type is a pair.
Definition type_traits.hxx:122
Concept to check if a type is a pointer.
Definition type_traits.hxx:174
Concept to check if a type is a reference.
Definition type_traits.hxx:135
Concept to check if two types are the same.
Definition type_traits.hxx:387
Concept to check if a type is a scoped enumeration (enum class).
Definition type_traits.hxx:161
Concept to check if a type is signed.
Definition type_traits.hxx:226
Concept to check if a type is std::string or std::wstring.
Definition type_traits.hxx:82
Concept to check if a type is trivially copyable.
Definition type_traits.hxx:305
Concept to check if a type has a trivial destructor.
Definition type_traits.hxx:318
Concept to check if a type is unsigned.
Definition type_traits.hxx:239
Concept to check if a variant type contains a specific type.
Definition type_traits.hxx:292
Concept to check if a type is a variant.
Definition type_traits.hxx:278
Main namespace for the StormByte library.
Modern C++20 concepts for type checking.