xentara-utils v1.1
Xentara utilities library
|
Tools and utilities. More...
Namespaces | |
namespace | byteSwap |
namespace | deprecated |
Classes | |
class | Defer |
A class that executes a callable at destruct time. More... | |
class | DeferThrowing |
A class that executes a callable at destruct time, catching exceptions if necessary. More... | |
class | DisableCopy |
A class that can be neither copied nor moved. More... | |
class | Hash |
A hash object with extended functionality. More... | |
struct | IsArithmetic |
Determines if a type is an arithmetic type, but not a bool or a special character type. More... | |
struct | IsBool |
Determines if a type is a Boolean type. More... | |
struct | IsCharType |
Determines if a type is a special character type. More... | |
struct | IsIeeeFloatingPoint |
Determines if a type is an IEEE floating point. More... | |
struct | IsIntegral |
Determines if a type is an integral type, but not a bool or a special character type. More... | |
struct | IsNothrowStringViewable |
Determines if a type can be converted to a string view without throwing exceptions. More... | |
struct | IsNothrowStringViewConstructible |
Determines if a type can be constructed from a string view without throwing exceptions. More... | |
struct | IsSame |
Determines if two types are the same, without taking into account qualifiers or references. More... | |
struct | IsStringType |
Determines if a type is a specialization of std::basic_string. More... | |
struct | IsStringViewable |
Determines if a type can be converted to a string view. More... | |
struct | IsStringViewConstructible |
Determines if a type can be constructed from a string view. More... | |
struct | IsStringViewType |
Determines if a type is a specialization of std::basic_string_view. More... | |
struct | NotCopyMove |
Checks whether a parameter pack doesn't consist of a single element with a specific type. More... | |
struct | ParameterPack |
A marker for a pack of parameters. More... | |
class | Unique |
A class that can be moved but not copied. More... | |
class | UnownedPointer |
A non-owning pointer that is interface compatible with std::unique_ptr. More... | |
class | UnownedPointer< Element[], Deleter > |
Template specialization of UnownedPointer for array types. More... | |
Concepts | |
concept | Integral |
Determines if a type is an integral type, but not a bool or a special character type. | |
concept | SignedIntegral |
Determines if a type is a signed integral type, but not a bool or a special character type. | |
concept | UnsignedIntegral |
Determines if a type is an integral type, but not a bool or a special character type. | |
concept | Arithmetic |
Determines if a type is an arithmetic type, but not a bool or a special character type. | |
concept | IeeeFloatingPoint |
A concept describing an IEEE floating point. | |
concept | Bool |
Determines if a type is a Boolean type. | |
concept | CharType |
Determines if a type is a special character type. | |
concept | StringType |
Determines if a type is a specialization of std::basic_string. | |
concept | StringViewType |
Determines if a type is a specialization of std::basic_string_view. | |
concept | StringViewable |
Determines if a type can be converted to a string view. | |
concept | StringViewConstructible |
Determines if a type can be constructed from a string view. | |
concept | SameAs |
Determines if two types are the same, without taking into account qualifiers or references. | |
concept | OneOf |
Determines if a type is one of a list of allowed types. | |
concept | Singleton |
A concept used for singleton classes. | |
concept | NullablePointer |
A concept for pointers that can be nulled. | |
concept | Allocator |
A concept for pointers that can be nulled. | |
concept | StdHashable |
This concept checks whether a class has a proper specialization for std::hash. | |
Typedefs | |
template<typename Key , typename Value , typename Allocator = std::allocator<std::pair<const Key, Value>>> | |
using | unordered_map = std::unordered_map< Key, Value, Hash, std::equal_to<>, Allocator > |
Type alias for a hash table that uses xentara::utils::tools::hash as hash and generic std::equal_to<> as key compare. More... | |
template<typename Key , typename Allocator = std::allocator<Key>> | |
using | unordered_set = std::unordered_set< Key, Hash, std::equal_to<>, Allocator > |
Type alias for a hash table based set that uses xentara::utils::tools::hash as hash and generic std::equal_to<> as key compare. More... | |
template<typename Key , typename Value , typename Allocator = std::allocator<std::pair<const Key, Value>>> | |
using | unordered_multimap = std::unordered_multimap< Key, Value, Hash, std::equal_to<>, Allocator > |
Type alias for a multi-hash table that uses xentara::utils::tools::hash as hash and generic std::equal_to<> as key compare. More... | |
template<typename Key , typename Allocator = std::allocator<Key>> | |
using | unordered_multiset = std::unordered_multiset< Key, Hash, std::equal_to<>, Allocator > |
Type alias for a hash table based multi-set that uses xentara::utils::tools::hash as hash and generic std::equal_to<> as key compare. More... | |
template<typename Key , typename Value , typename Allocator = std::allocator<std::pair<const Key, Value>>> | |
using | map = std::map< Key, Value, std::less<>, Allocator > |
Type alias for a hash table that uses xentara::utils::tools::hash as hash and generic std::less<> as key compare. More... | |
template<typename Key , typename Allocator = std::allocator<Key>> | |
using | set = std::set< Key, std::less<>, Allocator > |
Type alias for a hash table based set that uses xentara::utils::tools::hash as hash and generic std::less<> as key compare. More... | |
template<typename Key , typename Value , typename Allocator = std::allocator<std::pair<const Key, Value>>> | |
using | multimap = std::multimap< Key, Value, std::less<>, Allocator > |
Type alias for a multi-hash table that uses xentara::utils::tools::hash as hash and generic std::less<> as key compare. More... | |
template<typename Key , typename Allocator = std::allocator<Key>> | |
using | multiset = std::multiset< Key, std::less<>, Allocator > |
Type alias for a hash table based multi-set that uses xentara::utils::tools::hash as hash and generic std::less<> as key compare. More... | |
template<std::size_t kSize> | |
using | IntegerWithSize = __sized_integer_type__< kSize > |
A template that can be used to find an integer type with a certain size. More... | |
template<std::size_t kSize> | |
using | UnsignedIntegerWithSize = __sized_unsigned_integer_type__< kSize > |
A template that can be used to find an unsigned integer type with a certain size. More... | |
template<std::size_t kSize> | |
using | ExtendedIntegerWithSize = __sized_extended_integer_type__< kSize > |
A template that can be used to find a possibly extended integer type with a certain size. More... | |
template<std::size_t kSize> | |
using | ExtendedUnsignedIntegerWithSize = __sized_extended_unsigned_integer_type__< kSize > |
A template that can be used to find a possibly extended unsigned integer type with a certain size. More... | |
template<typename Type > | |
using | StringViewableCharType = __string_viewable_char_type__< Type > |
A template that can be used to find the character type of the string view that a type can be converted to. More... | |
template<typename Type > | |
using | StringViewableViewType = std::basic_string_view< StringViewableCharType< Type > > |
A template that can be used to find the string view type that a type can be converted to. More... | |
template<typename Type > | |
using | StringViewConstructibleCharType = __string_view_constructible_char_type__< Type > |
A template that can be used to find the character type of the string view that a type can be constructed from. More... | |
template<typename Type > | |
using | StringViewConstructibleViewType = std::basic_string_view< StringViewConstructibleCharType< Type > > |
A template that can be used to find the string view type that a type can be constructed from. More... | |
Functions | |
template<typename To , typename From > requires (sizeof(To) == sizeof(From) && std::is_trivially_copyable_v<From> && std::is_trivially_copyable_v<To>) | |
constexpr auto | bit_cast (const From &from) noexcept -> To |
Replacement for std::bit_cast on systems where it is missing. More... | |
template<typename Type , typename... PackTypes> | |
constexpr auto | countOfType () noexcept -> std::size_t |
Returns the number of times a type appears in a parameter pack. More... | |
template<typename Type , typename... PackTypes> | |
constexpr auto | get (PackTypes &&... pack) noexcept -> decltype(auto) |
Gets the first member of a certain type from a parameter pack. More... | |
template<typename Type , auto kFallback, typename... PackTypes> | |
constexpr auto | getOr (PackTypes &&... pack) noexcept -> decltype(auto) |
Gets the first value of a certain type from a parameter pack. More... | |
template<typename Type , typename... PackTypes> | |
constexpr auto | indexOfType () noexcept -> std::size_t |
Returns the index of a type within a parameter pack. More... | |
auto | unreachable () -> void |
This is a dummy function that lets the compiler that this part of the code cannot be reached. More... | |
template<typename Visitor , typename... Values> | |
constexpr auto | visit (Visitor &&visitor, Values &&... values) -> void |
Executes a callable visitor for a series of values. More... | |
template<typename Visitor , typename Tuple > requires requires { std::tuple_size<std::remove_reference_t<Tuple>>::value; } | |
constexpr auto | visitTuple (Visitor &&visitor, Tuple &&tuple) -> void |
Executes a callable visitor for all the members of a tuple. More... | |
Variables | |
constexpr bool | kHasConstexprBitCast |
Constant describing whether bit_cast is constexpr. More... | |
template<typename > | |
constexpr bool | kAlwaysFalse |
A value of false. More... | |
template<typename... Parameters> | |
constexpr ParameterPack< Parameters... > | kParameterPack |
A marker for a pack of parameters. More... | |
template<typename Type , typename... ParameterPack> | |
constexpr bool | kNotCopyMove |
Checks whether a parameter pack contains a single element with a specific type. More... | |
Tools and utilities.
This namespace contains various tools and utilities, mainly for template meta programming.
using xentara::utils::tools::ExtendedIntegerWithSize = typedef __sized_extended_integer_type__<kSize> |
A template that can be used to find a possibly extended integer type with a certain size.
This type alias is equivalent to IntegerWithSize, except that it may return extended integer types like *__int128*.
If there is no integer or extended integer type with the specified size, this type is not defined.
using xentara::utils::tools::ExtendedUnsignedIntegerWithSize = typedef __sized_extended_unsigned_integer_type__<kSize> |
A template that can be used to find a possibly extended unsigned integer type with a certain size.
This type alias is equivalent to UnsignedIntegerWithSize, except that it may return extended integer types like unsigned __int128.
If there is no unsigned integer or extended unsigned integer type with the specified size, this type is not defined.
using xentara::utils::tools::IntegerWithSize = typedef __sized_integer_type__<kSize> |
A template that can be used to find an integer type with a certain size.
If there is no integer type with the specified size, this type is not defined.
using xentara::utils::tools::map = typedef std::map<Key, Value, std::less<>, Allocator> |
Type alias for a hash table that uses xentara::utils::tools::hash as hash and generic std::less<> as key compare.
using xentara::utils::tools::multimap = typedef std::multimap<Key, Value, std::less<>, Allocator> |
Type alias for a multi-hash table that uses xentara::utils::tools::hash as hash and generic std::less<> as key compare.
using xentara::utils::tools::multiset = typedef std::multiset<Key, std::less<>, Allocator> |
Type alias for a hash table based multi-set that uses xentara::utils::tools::hash as hash and generic std::less<> as key compare.
using xentara::utils::tools::set = typedef std::set<Key, std::less<>, Allocator> |
Type alias for a hash table based set that uses xentara::utils::tools::hash as hash and generic std::less<> as key compare.
using xentara::utils::tools::StringViewableCharType = typedef __string_viewable_char_type__<Type> |
A template that can be used to find the character type of the string view that a type can be converted to.
If the given type cannot be converted to a string view, or if it can be converted to multiple types of string view, this type is not defined.
using xentara::utils::tools::StringViewableViewType = typedef std::basic_string_view<StringViewableCharType<Type> > |
A template that can be used to find the string view type that a type can be converted to.
If the given type cannot be converted to a string view, or if it can be converted to multiple types of string view, this type is not defined.
using xentara::utils::tools::StringViewConstructibleCharType = typedef __string_view_constructible_char_type__<Type> |
A template that can be used to find the character type of the string view that a type can be constructed from.
If the given type cannot be constructed from a string view, or if it can be constructed from multiple types of string view, this type is not defined.
using xentara::utils::tools::StringViewConstructibleViewType = typedef std::basic_string_view<StringViewConstructibleCharType<Type> > |
A template that can be used to find the string view type that a type can be constructed from.
If the given type cannot be constructed from a string view, or if it can be constructed from multiple types of string view, this type is not defined.
using xentara::utils::tools::unordered_map = typedef std::unordered_map<Key, Value, Hash, std::equal_to<>, Allocator> |
Type alias for a hash table that uses xentara::utils::tools::hash as hash and generic std::equal_to<> as key compare.
using xentara::utils::tools::unordered_multimap = typedef std::unordered_multimap<Key, Value, Hash, std::equal_to<>, Allocator> |
Type alias for a multi-hash table that uses xentara::utils::tools::hash as hash and generic std::equal_to<> as key compare.
using xentara::utils::tools::unordered_multiset = typedef std::unordered_multiset<Key, Hash, std::equal_to<>, Allocator> |
Type alias for a hash table based multi-set that uses xentara::utils::tools::hash as hash and generic std::equal_to<> as key compare.
using xentara::utils::tools::unordered_set = typedef std::unordered_set<Key, Hash, std::equal_to<>, Allocator> |
Type alias for a hash table based set that uses xentara::utils::tools::hash as hash and generic std::equal_to<> as key compare.
using xentara::utils::tools::UnsignedIntegerWithSize = typedef __sized_unsigned_integer_type__<kSize> |
A template that can be used to find an unsigned integer type with a certain size.
If there is no unsigned integer type with the specified size, this type is not defined.
|
constexprnoexcept |
Replacement for std::bit_cast on systems where it is missing.
This is an implementation of std::bit_cast for platforms on which is is missing. On platforms that supply an std::bit_cast, this is simply a using-directive for std::bit_cast.
|
constexprnoexcept |
Returns the number of times a type appears in a parameter pack.
This function counts how many times a parameter appears in a parameter pack. The type is considered matching if std::remove_cvref_t<PackType> is the same as the given type.
Type | The type to search for |
...PackTypes | The types in the parameter pack |
|
constexprnoexcept |
Gets the first member of a certain type from a parameter pack.
This function extracts the first parameter whose type matches that in a parameter pack. The type is considered matching if std::remove_cvref_t<PackType> is the same as the given type.
Type | The desired type. |
...PackTypes | The types in the parameter pack. Must contain at least one instance of Type. |
...pack | The parameter pack |
|
constexprnoexcept |
Gets the first value of a certain type from a parameter pack.
This function extracts the first value whose type matches that in a parameter pack. The type is considered matching if std::remove_cvref_t<PackType> is the same as the given type.
This function returns a fallback value if none of the pack does not contain any suitable types. The fallback value is contained in the template parameter kFallback. kFallback must be a value that can be implicitly converted to Type.
Not all C++ types can be used as template parameters. To provide a fallback value of a type that is not suitable for use as a template parameter, you can use the following workaround:
Type | The desired type. |
kFallback | The value to return if the pack does not contain any suitable types. |
...PackTypes | The types in the parameter pack |
...pack | The parameter pack |
|
constexprnoexcept |
Returns the index of a type within a parameter pack.
This function gets the index of a type within a parameter pack. The type is considered matching if std::remove_cvref_t<PackType> is the same as the given type.
Type | The type to search for |
...PackTypes | The types in the parameter pack |
auto xentara::utils::tools::unreachable | ( | ) | -> void |
This is a dummy function that lets the compiler that this part of the code cannot be reached.
|
constexpr |
Executes a callable visitor for a series of values.
visitor | The visitor |
...values | The values |
|
constexpr |
Executes a callable visitor for all the members of a tuple.
visitor | The visitor |
tuple | The tuple |
|
constexpr |
A value of false.
This constant can be used to trigger static asserts unconditionally in template instantiations where the assert needs to be always false, but dependend on a parameter.
|
constexpr |
Constant describing whether bit_cast is constexpr.
|
constexpr |
Checks whether a parameter pack contains a single element with a specific type.
This value checks whether a parameter pack doesn't consist of exactly one parameter that is a possibly CV-qualified version of a certain type, or a possibly CV-qualified reference to that type. This can be used to prevent templated constructors from qualifying as copy and/or move constructors.
Type | The type to check for |
ParameterPack | The parameter pack |
|
constexpr |
A marker for a pack of parameters.
This is an empty object that can be used in meta programming to represent a parameter pack. It is used in a similar way to std::in_place_type: it can be passed to a function to select an overload that uses a certain pack of parameter templates