Skip to content
Welcome to the new CppUtils documentation!

Namespace: CppUtils::Type

template<class T>
concept ArithmeticInteger = std::integral<std::remove_cvref_t<T>> and not std::same_as<std::remove_cvref_t<T>, bool> and not Character<T>;
template<class Function, class... Args>
concept Callable = std::invocable<Function, Args...>;
template<class T>
concept Character = IsOneOf<std::remove_cvref_t<T>, char, wchar_t, char8_t, char16_t, char32_t>;
template<class T>
concept DefaultConstructible = std::is_default_constructible_v<T>;
template<class T>
concept Dereferenceable = requires (T value) { *value; };
template<class Type, class Expected>
concept Exact = std::same_as<std::remove_cvref_t<Type>, Expected>;
template<class T>
concept Function = std::is_function_v<T>;
template<class T>
concept FunctionPointer = isFunctionPointer<T>;
template<class T>
concept HasReturnValue = not std::same_as<std::invoke_result_t<T>, void>;
template<class T>
concept IsHashable = requires (std::remove_cvref_t<T>& a) { { std::hash<std::remove_cvref_t<T>>{}(a) } -> std::convertible_to<std::size_t>; };
template<class Type, class... Types>
concept IsOneOf = (std::same_as<Type, Types> or ...);
template<class Function, class... Args>
concept NotCallable = not Callable<Function, Args...>;
template<class T>
concept Numeric = std::integral<T> or std::floating_point<T>;
template<class T>
concept Printable = requires (T value) { { std::cout <<value } -> std::same_as<std::ostream&>; };
template<class Source, class Value>
concept Readable = requires (Source source, Value& value) { source.read(value); } or requires (Source source) { { source.read() } -> std::convertible_to<Value>; } or requires (Source source) { { source.template read<Value>() } -> std::convertible_to<Value>; };
template<class T>
concept Serializable = requires (const T& value, std::vector<std::byte>& buffer, std::span<const std::byte>& view) { { serialize(value, buffer) } -> std::same_as<void>; { deserialize<std::remove_cvref_t<T>>(view) } -> std::same_as<std::expected<std::remove_cvref_t<T>, std::string_view>>; };
template<class Range>
concept SizedRandomAccessRange = std::ranges::random_access_range<Range> and std::ranges::sized_range<Range>;

Concept satisfied if a type is both a random-access range and a sized range.

template<class T, template<class...> class IncompleteType> concept Specializes = isSpecializationOfTypes<std::remove_cvref_t<T>, IncompleteType>;
template<class T, template<auto...> class IncompleteType> concept SpecializesValue = isSpecializationOfValues<std::remove_cvref_t<T>, IncompleteType>;
template<class T>
concept TextSerializable = requires (const T& value, std::string& buffer) { { Text::Serializer<std::remove_cvref_t<T>>::serialize(value, buffer) } -> std::same_as<void>; { Text::Serializer<std::remove_cvref_t<T>>::deserialize(std::string_view{buffer}) } -> std::same_as<std::expected<std::remove_cvref_t<T>, std::string_view>>; };
template<class T>
concept Trivial = TriviallyConstructible<T> and TriviallyDestructible<T> and TriviallyCopyable<T> and TriviallyMoveConstructible<T> and TriviallyMoveAssignable<T>;
template<class T>
concept TriviallyConstructible = std::is_trivially_constructible_v<T>;
template<class T>
concept TriviallyCopyable = std::is_trivially_copyable_v<T>;
template<class T>
concept TriviallyDestructible = std::is_trivially_destructible_v<T>;
template<class T>
concept TriviallyMoveAssignable = std::is_trivially_move_assignable_v<T>;
template<class T>
concept TriviallyMoveConstructible = std::is_trivially_move_constructible_v<T>;
template<class Target, class Value>
concept Writable = requires (Target target, Value value) { target.write(value); };