Namespace type_safe

Description

\exclude

Namespaces

compact_enum_detail\exclude
constraints
detail\exclude
literals
strong_typedef_opSome operations for ts::strong_typedef.
types

Classes

array_refA reference to an array of objects of type T.
assertion_verifierA Verifier for ts::constrained_type that DEBUG_ASSERTs the constraint.
basic_optionalAn optional type, i.e
basic_variantAn improved union storing at most one of the given types at a time (or possibly none).
booleanA type safe boolean class.
checked_arithmeticAn ArithmeticPolicy where under/overflow throws an exception
clamping_verifierA Verifier for ts::constrained_type that clamps the value to make it valid.
compact_bool_policyA CompactPolicy for ts::compact_optional_storage for boolean types.
compact_container_policyA CompactPolicy for ts::compact_optional_storage for container types.
compact_enum_policyA CompactPolicy for ts::compact_optional_storage for enumeration types.
compact_floating_point_policyA CompactPolicy for ts::compact_optional_storage for floating point types.
compact_integer_policyA CompactPolicy for ts::compact_optional_storage for integer types.
compact_optional_storageA StoragePolicy for ts::basic_optional that is more space efficient than ts::direct_optional_storage.
constrain_errorThe exception class thrown by the [ts::throwing_verifier]().
constrained_modifierA proxy class to provide write access to the stored value of a ts::constrained_type.
constrained_typeA value of type T that always fulfills the predicate Constraint.
constrained_type< T &, Constraint, Verifier >Specialization of ts::constrained_type for references.
default_arithmeticAn ArithmeticPolicy that behaves like the default integer implementations: Signed under/overflow is UB, unsigned under/overflow wraps around
deferred_constructionA tiny wrapper to create an object without constructing it yet.
derived_typeTag type to specify the derived type of a ts::downcast.
difference_tA type modelling the difference between two ts::index_t objects.
fallback_variant_policyA variant policy for ts::basic_variant that uses a fallback type.
flagA type safe flag, it can either be true or false.
flag_setA set of flags where each one can either be 0 or 1.
flag_set_traitsTraits for the enum used in a ts::flag_set.
floating_pointA type safe floating point class.
function_ref
function_ref< Return(Args...)>A reference to a function.
hashableInherit from it in the std::hash<StrongTypedef> specialization to make it hashable like the underlying type
index_tA type modelling an index into an array.
integerA type safe integer class.
noflag_tTag type to mark a [ts::flag_set]() without any flags set.
null_verifierA Verifier for ts::constrained_type that doesn't check the constraint.
nullopt_tTag type to mark a ts::basic_optional without a value
nullvar_tTag type to mark a ts::basic_variant without a value
object_refA reference to an object of some type T.
optional_storage_policy_forSelects the storage policy used when rebinding a ts::basic_optional.
optional_storage_policy_for< basic_optional< StoragePolicy > >Specialization of ts::optional_storage_policy_for for ts::basic_optional itself.
optional_storage_policy_for< object_ref< T, XValue > >Sets the ts::basic_optional storage policy for ts::object_ref to ts::reference_optional_storage.
optional_storage_policy_for< T & >Specialization of ts::optional_storage_policy_for for lvalue references.
optional_storage_policy_for< T && >Specialization of ts::optional_storage_policy_for for rvalue references.
optional_variant_policyA variant policy for ts::basic_variant that creates a variant with explicit empty state.
output_parameterA tiny wrapper modelling an output parameter of a function.
reference_optional_storageA StoragePolicy for ts::basic_optional that allows optional references.
strong_typedefA strong typedef emulation.
tagged_unionA tagged union.
throwing_verifierA Verifier for ts::constrained_type that throws an exception in case of failure.
undefined_behavior_arithmeticAn ArithmeticPolicy where under/overflow is always undefined behavior, albeit checked when assertions are enabled
union_typeTag type so no explicit template instantiation of function parameters is required
union_typesVery basic typelist

Functions

abs overloadReturns: The absolute value of a built-in signed integer
abs overloadReturns: The absolute value of an ts::integer
abs overloadReturns: i unchanged
advance\effects Increments the ts::index_t by the specified distance
atReturns: The ith element of obj by invoking its operator[] with the ts::index_t converted to std::size_t
clampReturns a copy of val so that it is in the given ts::constraints::closed_interval
combo overloadConverts a flag mask to a flag combination.
combo overloadConverts a ts::flag_set to a flag combination.
constrainCreates a ts::constrained_type with the default verifier, ts::assertion_verifier.
copy overloadReturns: A ts::optional<T> containing a copy of the value of ref if there is any value
copy overloadReturns: A new object containing a copy of the referenced object
copy overload\effects Copies the type currently stored in one ts::tagged_union to another
cref overload\group object_ref_ref
cref overloadCreates a ts::array_ref to const.
cref overload\group array_ref_cref
destroy\effects Destroys the type currently stored in the ts::tagged_union, by calling u.destroy(union_type<T>{})
distanceReturns: The distance between two ts::index_t objects, i.e
downcast overloadCasts an object of base class type to the derived class type.
downcast overload\group downcast_tag
get overloadAccesses the underlying value.
get overload\group strong_typedef_get
has_value overload\group optional_comp_null
make_boundedCreates a ts::bounded_type to a specified ts::constraints::closed_interval.
make_bounded_exclusiveCreates a ts::bounded_type to a specified ts::constraints::open_interval.
make_clampedCreates a ts::clamped_type from the specified ts::constraints::closed_interval.
make_optional overloadReturns: A new ts::optional<T> storing a copy of t
make_optional overloadReturns: A new ts::optional<T> with a value created by perfectly forwarding args to the constructor
make_signed overloadReturns: A new integer of the corresponding signed integer type
make_signed overloadReturns: A new ts::integer of the corresponding signed integer type
make_unsigned overloadReturns: A new integer of the corresponding unsigned integer type
make_unsigned overloadReturns: A new ts::integer of the corresponding unsigned integer type
mask overloadConverts a flag combination to a flag mask.
mask overload\group mask_combo
mask overloadConverts a ts::flag_set to a flag mask.
move overloadReturns: A ts::optional<T> containing a copy of the value of ref created by move constructing if there is any value
move overload\group object_ref_copy
move overload\group union_copy_move \module variant \unique_name *move_union
narrow_cast overloadReturns: An arithmetic type with the same value as in source, but converted to to a different type
narrow_cast overloadReturns: A ts::integer with the same value as source but of a different type
narrow_cast overloadReturns: A ts::floating_point with the same value as source but of a different type
nextReturns: The ts::index_t that is dist greater than index
operator!= overloadts::boolean in-equality comparison.
operator!= overload\group boolean_comp_unequal
operator!= overloadts::flag in-equality comparison.
operator!= overload\group flag_unequal
operator!= overload\group flag_set_equal
operator!= overload\group ref_compare
operator!= overload\group variant_comp_t
operator!= overload\group variant_comp
operator""_boundCreates a static bound for ts::bounded_type.
operator""_boundu\group bound_lit
operator""_d\module types
operator""_f\module types
operator""_i\module types
operator""_i16\module types
operator""_i32\module types
operator""_i64\module types
operator""_i8\module types
operator""_isize\module types
operator""_u\module types
operator""_u16\module types
operator""_u32\module types
operator""_u64\module types
operator""_u8\module types
operator""_usize\module types
operator& overload\group bitwise_op
operator& overloadChecks whether a combination of flags is set in a.
operator& overload\group bitwise_and_check
operator+ overloadReturns: The given ts::index_t advanced by the given ts::distance_t
operator+ overload\group index_distance_plus
operator- overloadReturns: The given ts::index_t advanced backwards by the given ts::distance_t
operator- overloadReturns: Returns the distance between two indices
operator< overloadReturns: The result of the comparison of the stored floating point value in the ts::floating_point
operator< overload\group variant_comp_t
operator< overload\group variant_comp
operator<<ts::boolean output operator
operator<= overload\group variant_comp_t
operator<= overload\group variant_comp
operator== overloadts::boolean equality comparison.
operator== overload\group boolean_comp_equal
operator== overload\exclude
operator== overloadts::flag equality comparison.
operator== overload\group flag_equal
operator== overloadflag_set equality comparison.
operator== overload\group flag_set_equal
operator== overloadReturns: The result of the comparison of the stored integer value in the ts::integer
operator== overloadComparison operator for ts::object_ref.
operator== overload\group ref_compare
operator== overload\group variant_comp_t
operator== overloadCompares two ts::basic_variants.
operator> overload\group variant_comp_t
operator> overload\group variant_comp
operator>= overload\group variant_comp_t
operator>= overload\group variant_comp
operator>>ts::boolean input operator
operator^ overload\group bitwise_op
operator| overloadReturns: The same as a Op= b
operator| overload\group bitwise_op
opt_cref overloadReturns: A ts::optional_ref to const to the same target as ref
opt_cref overloadReturns: A ts::optional_ref to the given object
opt_cref overloadReturns: A ts::optional_ref to const to the stored value in opt
opt_cref overloadReturns: A ts::optional_ref<T> to const to the pointee of ptr or nullopt
opt_ref overloadReturns: A ts::optional_ref to the same target as ref
opt_ref overloadReturns: A ts::optional_ref to the given object
opt_ref overloadReturns: A ts::optional_ref to the stored value in opt
opt_ref overloadReturns: A ts::optional_ref<T> to the pointee of ptr or nullopt
opt_xref overloadReturns: A ts::optional_xvalue_ref<T> to the pointee of ptr or nullopt
opt_xref overloadReturns: A ts::optional_xvalue_ref<T> to the given object
out overloadReturns: A new ts::output_parameter using the reference obj as output.
out overloadReturns: A new ts::output_parameter using the ts::deferred_construction as output.
prevReturns: The ts::index_t that is dist smaller than index
ref overloadCreates a (const) ts::object_ref.
ref overloadCreates a ts::array_ref.
ref overload\group array_ref_ref
sanitizeCreates a ts::constrained_type using the ts::throwing_verifier.
sanitize_boundedCreates a ts::bounded_type to a specified ts::constraints::closed_interval.
sanitize_bounded_exclusiveCreates a ts::bounded_type to a specified ts::constraints::open_interval, using ts::throwing_verifier.
tagCreates a new ts::tagged_type.
TYPE_SAFE_DETAIL_MAKE_OP overloadCompares a ts::constrained_type.
TYPE_SAFE_DETAIL_MAKE_OP overload\group optional_comp_null
TYPE_SAFE_DETAIL_MAKE_PREDICATE\group comparison_functors
visit overloadVisits a ts::basic_optional
visit overloadVisits a ts::basic_variant
with overloadWith operation for ts::constrained_type
with overloadWith operation for ts::object_ref
with overloadWith operation for ts::array_ref
with overload\effects If the union is empty, does nothing
with overload\group union_with
with overload\effects If the variant is empty, does nothing
with overload\group variant_with
xref overloadCreates a ts::xvalue_ref.
xref overloadCreates a ts::array_xvalue_ref.
xref overload\group array_xvalue_ref_ref

Typedefs

Typedefs (arithmetic_policy.hpp)

using arithmetic_policy_default = default_arithmetic

Typedefs (bounded_type.hpp)

template <typename T, bool LowerInclusive, bool UpperInclusive, typename LowerBound = constraints::dynamic_bound, typename UpperBound = constraints::dynamic_bound, typename Verifier = assertion_verifier>
using bounded_type = constrained_type< T, constraints::bounded< T, LowerInclusive, UpperInclusive, LowerBound, UpperBound >, Verifier >

An alias for [ts::constrained_type]() that uses [ts::constraints::bounded]() as its Constraint. \notes This is some type where the values must be in a certain interval.

Mentioned in:

Getting Started / Type safe building blocks

Changelog / Type Safe Building Blocks:

template <typename T, typename LowerBound = constraints::dynamic_bound, typename UpperBound = constraints::dynamic_bound>
using clamped_type = constrained_type< T, constraints::closed_interval< T, LowerBound, UpperBound >, clamping_verifier >

An alias for [ts::constrained_type]() that uses [ts::constraints::closed_interval]() as its Constraint and [ts::clamping_verifier]() as its Verifier. \notes This is some type where the values are always clamped so that they are in a certain interval.

Mentioned in:

Getting Started / Type safe building blocks

Typedefs (compact_optional.hpp)

template <class CompactPolicy>
using compact_optional = basic_optional< compact_optional_storage< CompactPolicy > >

An alias for [ts::basic_optional]() using [ts::compact_optional_storage]() with the given CompactPolicy. \module optional

Mentioned in:

Getting Started / Optional & Variant

Typedefs (constrained_type.hpp)

template <typename T, class Constraint, class Verifier = assertion_verifier>
using constrained_ref = constrained_type< T &, Constraint, Verifier >

Alias for ts::constrained_type<T&>.

Mentioned in:

Changelog / Type Safe Building Blocks:

template <typename T, class Constraint>
using tagged_type = constrained_type< T, Constraint, null_verifier >

An alias for [ts::constrained_type]() that never checks the constraint.

It is useful for creating tagged types: The Constraint - which does not need to be a predicate anymore - is a "tag" to differentiate a type in different states. For example, you could have a "sanitized" value and a "non-sanitized" value that have different types, so you cannot accidentally mix them. \notes It is only intended if the Constraint cannot be formalized easily and/or is expensive. Otherwise [ts::constrained_type]() is recommended as it does additional runtime checks in debug mode.

Mentioned in:

Getting Started / Type safe building blocks

Examples / constrained.cpp

template <typename T, class Constraint>
using tagged_ref = constrained_ref< T, Constraint, null_verifier >

An alias for [ts::tagged_type]() with reference.

Typedefs (flag_set.hpp)

template <typename Enum>
using flag_combo = detail::flag_combo< Enum >

Represents a combination of multiple flags.

This type is created when you write a | b, where a and b are enumerators of a flag.

Objects of this type and the flags themselves are flag combinations. You can compare two flag combinations, combine two with | and use them in [ts::flag_set]() to set or toggle a combination of flags. Creating the complement with ~ will create a [ts::flag_mask]().

\requires Enum must be a flag, i.e. valid with the [ts::flag_set_traits]().

template <typename Enum>
using flag_mask = detail::flag_mask< Enum >

Represents a mask of flags.

This type is created when you write ~a, where a is the enumerator of a flag.

Objects of this type are flag masks. You can compare two flag masks, combine them with & and use them in [ts::flag_set]() to clear a combination of flags. Creating the complement with ~ will create a [ts::flag_combo]().

\requires Enum must be a flag, i.e. valid with the [ts::flag_set_traits]().

Typedefs (integer.hpp)

template <class Integer>
using make_signed_t = typename detail::make_signed< Integer >::type

[std::make_signed]() for [ts::integer](). \module types \exclude target

template <class Integer>
using make_unsigned_t = typename detail::make_unsigned< Integer >::type

[std::make_unsigned]() for [ts::integer](). \module types \exclude target

Typedefs (optional.hpp)

template <typename T>
using optional = basic_optional< direct_optional_storage< T > >

A [ts::basic_optional]() that uses [ts::direct_optional_storage<T>](). \module optional

Mentioned in:

Getting Started / Optional & Variant

Examples / optional.cpp

template <typename T>
using optional_for = basic_optional< direct_optional_storage< int > >::rebind< T >

Uses [ts::optional_storage_policy_for]() to select the appropriate [ts::basic_optional]().

By default, it uses [ts::direct_optional_storage](). \notes If T is void, optional_for will also be void. \module optional

Mentioned in:

Changelog / Optional & Variant:

Typedefs (optional_ref.hpp)

template <typename T>
using optional_ref = basic_optional< reference_optional_storage< T > >

A [ts::basic_optional]() that uses [ts::reference_optional_storage](). It is an optional reference. \notes T is the type without the reference, i.e. optional_ref<int>. \module optional

Mentioned in:

Getting Started / Optional & Variant

Changelog / Optional & Variant:

Examples / optional.cpp

template <typename T>
using optional_xvalue_ref = basic_optional< reference_optional_storage< T, true > >

A [ts::basic_optional]() that uses [ts::reference_optional_storage]() with XValue being true. It is an optional reference to an xvalue, i.e. an lvalue that can be moved from, like returned by std::move(). \notes T is the type without the reference, i.e. optional_xvalue_ref<int>. \module optional

Typedefs (reference.hpp)

template <typename T>
using xvalue_ref = object_ref< T, true >

Convenience alias of [ts::object_ref]() where XValue is true.

Mentioned in:

Changelog / Vocabulary Types

template <typename T>
using array_xvalue_ref = array_ref< T, true >

Convenience alias for [ts::array_ref]() where XValue is true.

Typedefs (strong_typedef.hpp)

template <class StrongTypedef>
using underlying_type = decltype(detail::underlying_type(std::declval< typename std::decay< StrongTypedef >::type >()))

The underlying type of the [ts::strong_typedef](). \exclude target

Typedefs (types.hpp)

using int8_t = TYPE_SAFE_DETAIL_WRAP(integer, int8_t)

\module types

using int16_t = TYPE_SAFE_DETAIL_WRAP(integer, int16_t)

\module types

using int32_t = TYPE_SAFE_DETAIL_WRAP(integer, int32_t)

\module types

using int64_t = TYPE_SAFE_DETAIL_WRAP(integer, int64_t)

\module types

using uint8_t = TYPE_SAFE_DETAIL_WRAP(integer, uint8_t)

\module types

using uint16_t = TYPE_SAFE_DETAIL_WRAP(integer, uint16_t)

\module types

using uint32_t = TYPE_SAFE_DETAIL_WRAP(integer, uint32_t)

\module types

using uint64_t = TYPE_SAFE_DETAIL_WRAP(integer, uint64_t)

\module types

using int_fast8_t = TYPE_SAFE_DETAIL_WRAP(integer, int_fast8_t)

\module types

using int_fast16_t = TYPE_SAFE_DETAIL_WRAP(integer, int_fast16_t)

\module types

using int_fast32_t = TYPE_SAFE_DETAIL_WRAP(integer, int_fast32_t)

\module types

using int_fast64_t = TYPE_SAFE_DETAIL_WRAP(integer, int_fast64_t)

\module types

using uint_fast8_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_fast8_t)

\module types

using uint_fast16_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_fast16_t)

\module types

using uint_fast32_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_fast32_t)

\module types

using uint_fast64_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_fast64_t)

\module types

using int_least8_t = TYPE_SAFE_DETAIL_WRAP(integer, int_least8_t)

\module types

using int_least16_t = TYPE_SAFE_DETAIL_WRAP(integer, int_least16_t)

\module types

using int_least32_t = TYPE_SAFE_DETAIL_WRAP(integer, int_least32_t)

\module types

using int_least64_t = TYPE_SAFE_DETAIL_WRAP(integer, int_least64_t)

\module types

using uint_least8_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_least8_t)

\module types

using uint_least16_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_least16_t)

\module types

using uint_least32_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_least32_t)

\module types

using uint_least64_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_least64_t)

\module types

using intmax_t = TYPE_SAFE_DETAIL_WRAP(integer, intmax_t)

\module types

using uintmax_t = TYPE_SAFE_DETAIL_WRAP(integer, uintmax_t)

\module types

using intptr_t = TYPE_SAFE_DETAIL_WRAP(integer, intptr_t)

\module types

using uintptr_t = TYPE_SAFE_DETAIL_WRAP(integer, uintptr_t)

\module types

using ptrdiff_t = TYPE_SAFE_DETAIL_WRAP(integer, ptrdiff_t)

\module types

using size_t = TYPE_SAFE_DETAIL_WRAP(integer, size_t)

\module types

using int_t = TYPE_SAFE_DETAIL_WRAP(integer, int)

\module types

using unsigned_t = TYPE_SAFE_DETAIL_WRAP(integer, unsigned)

\module types

using float_t = TYPE_SAFE_DETAIL_WRAP(floating_point, std::float_t)

\module types

using double_t = TYPE_SAFE_DETAIL_WRAP(floating_point, std::double_t)

\module types

using bool_t = bool

Typedefs (variant.hpp)

template <typename T>
using variant_type = union_type< T >

Convenience alias for [ts::union_type](). \module variant

template <typename... Ts>
using variant_types = union_types< Ts... >

Convenience alias for [ts::union_types](). \module variant

template <typename Fallback, typename... OtherTypes>
using fallback_variant = basic_variant< fallback_variant_policy< Fallback >, Fallback, OtherTypes... >

A [ts::basic_variant]() using the [ts::fallback_variant_policy]().

This is a variant that is never empty, where exceptions on changing the type leaves it with a default-constructed object of the Fallback type. \requires Fallback must be nothrow default constructible. \module variant

Mentioned in:

Getting Started / Optional & Variant

using rarely_empty_variant_policy = detail::non_empty_variant_policy< false >

A variant policy for [ts::basic_variant]() that creates a variant which is rarely empty.

When changing the type of the variant, it will use a the move constructor with a temporary. If the move constructor throws, the variant will be left in the empty state. Putting it into the empty state explicitly is not allowed. \module variant

using never_empty_variant_policy = detail::non_empty_variant_policy< true >

A variant policy for [ts::basic_variant]() that creates a variant which is never empty.

Similar to [ts::rarely_empty_variant_policy]() but when the move constructor throws, it calls [std::terminate()](). \module variant

template <typename... Types>
using variant = typename detail::select_variant_policy< Types... >::type

A [ts::basic_variant]() with the recommended default semantics.

If the first type is [ts::nullvar_t]() it will use the [ts::optional_variant_policy](), which explicitly allows the empty state. Otherwise it will use the [ts::rarely_empty_variant_policy]() where it tries to avoid the empty state as good as possible. \notes If you pass [ts::nullvar_t]() as the first type, it is not actually one of the types that can be stored in the variant, but a tag to enable the empty state. \module variant

Variables

Variables (constrained_type.hpp)

T

Variables (flag_set.hpp)

constexpr noflag_t noflag

Tag object of type [ts::noflag_t]().

Variables (floating_point.hpp)

B

Variables (optional.hpp)

constexpr nullopt_t nullopt

Tag object of type [ts::nullopt_t](). \module optional

Mentioned in:

Examples / optional.cpp

lhs rhs false

lhs rhs rhs !lhs true true

lhs rhs rhs !lhs true !rhs lhs rhs Func

lhs rhs rhs !lhs true !rhs lhs rhs typename Args

Variables (variant.hpp)

constexpr nullvar_t nullvar

Tag object of type [ts::nullvar_t](). \module variant

lhs rhs rhs !lhs true !rhs typename Types

Mentioned in:

Source

Line 16 in include/type_safe/arithmetic_policy.hpp.






Add Discussion as Guest

Log in