4.4.0
|
|
Freundlich's C++ toolkit |
Cast helpers which provide more type information or do additional checks. More...
Classes | |
struct | dynamic_any_fun |
Function object that uses fcppt::cast::dynamic_any. More... | |
struct | dynamic_cross_fun |
Function object that uses fcppt::cast::dynamic_cross. More... | |
struct | dynamic_fun |
Function object that uses fcppt::cast::dynamic. More... | |
struct | float_to_int_fun |
Function object of fcppt::cast::float_to_int. More... | |
struct | int_to_enum_fun |
Function object of fcppt::cast::int_to_enum. More... | |
struct | int_to_float_fun |
Function object of fcppt::cast::int_to_float. More... | |
struct | size_fun |
Function object of fcppt::cast::size. More... | |
struct | static_cast_fun |
Function object that does a static_cast. More... | |
struct | to_signed_fun |
Function object of fcppt::cast::to_signed. More... | |
struct | to_unsigned_fun |
Function object of fcppt::cast::to_unsigned. More... | |
Typedefs | |
template<typename Type > | |
using | promote_int_type = typename fcppt::cast::detail::promote_int_type< Type >::type |
The promoted type of an integral type. | |
Functions | |
template<typename Fun , typename Res , typename Src > | |
constexpr decltype(auto) | apply (Src &&_src) |
Applies a cast to a source. | |
template<typename Derived , typename Base , typename = std::enable_if_t< fcppt::type_traits::is_base_of<std::remove_cv_t<Base>, std::remove_cv_t<Derived>>::value>> | |
fcppt::optional::reference< Derived > | dynamic (Base &_base) noexcept |
Converts between references of related types using dynamic_cast , returning an empty optional on failure. | |
template<typename Derived , typename Base > | |
fcppt::optional::reference< Derived > | dynamic_any (Base &_base) noexcept |
Converts between references using dynamic_cast , returning an empty optional on failure. | |
template<typename Dest , typename Src > | |
fcppt::optional::reference< Dest > | dynamic_cross (Src &_src) noexcept |
Tries a dynamic_cast on unrelated types, returning an empty optional on failure. | |
template<typename Dest , typename Enum , typename = std::enable_if_t<std::conjunction_v<std::is_integral<Dest>>, std::is_enum<Enum>>> | |
constexpr Dest | enum_to_int (Enum const _enum) noexcept |
Converts an enum to an int. | |
template<typename Enum , typename = std::enable_if<std::is_enum_v<Enum>>> | |
constexpr std::underlying_type_t< Enum > | enum_to_underlying (Enum const _enum) noexcept |
Converts an enum to its underlying type. | |
template<typename Dest , typename Source > | |
constexpr Dest | float_to_int (Source const _source) noexcept |
Converts a float to a signed int. | |
template<typename Dest , typename Source > | |
Dest | from_void_ptr (Source *const _ptr) noexcept |
Converts a void pointer to a different pointer. | |
template<typename Enum , typename Source , typename = std::enable_if_t<std::conjunction_v<std::is_enum<Enum>, std::is_integral<Source>>>> | |
constexpr Enum | int_to_enum (Source const _source) noexcept |
Converts an int to an enum. | |
template<typename Dest , typename Source > | |
constexpr Dest | int_to_float (Source const _source) noexcept |
Converts an int to a float. | |
template<typename Type > | |
constexpr fcppt::cast::promote_int_type< Type > | promote_int (Type const &_value) |
Promotes an integral type to int or unsigned int. | |
template<typename Dest , typename Source > | |
constexpr Dest | safe_numeric (Source const &_source) noexcept |
Safe numeric cast is a safer static_cast that forbids lossy conversions. | |
template<typename Dest , typename Source > | |
constexpr Dest | size (Source const _source) noexcept |
Converts a type to a similar type of different size. | |
template<typename Derived , typename Base > | |
std::enable_if_t< std::is_reference_v< Derived >, Derived > | static_downcast (Base &_source) noexcept |
Statically converts a reference to a base class to a reference to a derived class. | |
template<typename Dest , typename Source > | |
Dest | to_char_ptr (Source *const _source) noexcept |
Converts a pointer to a pointer to characters. | |
template<typename Type > | |
constexpr std::make_signed_t< Type > | to_signed (Type const _value) noexcept |
Converts an unsigned int to its signed type. | |
template<typename Source > | |
std::uintptr_t | to_uint_ptr (Source *const _ptr) noexcept |
Converts a pointer to a std::uintptr_t . | |
template<typename Type > | |
constexpr std::make_unsigned_t< Type > | to_unsigned (Type const _value) noexcept |
Converts a signed int to its unsigned type. | |
template<typename Type > | |
void | to_void (Type const &_value) noexcept |
Casts an expression to void. | |
template<typename Source > | |
void const * | to_void_ptr (Source const *const _ptr) noexcept |
Converts a pointer to const to a pointer to const void. | |
template<typename Source > | |
void * | to_void_ptr (Source *const _ptr) noexcept |
Converts a pointer to a pointer to void. | |
template<typename Dest , typename Source , typename = std::enable_if_t<std::conjunction_v<std::is_integral<Source>, std::is_integral<Dest>>>> | |
fcppt::optional::object< Dest > | truncation_check (Source const _source) |
Cast between integral types, checking for truncation. | |
Cast helpers which provide more type information or do additional checks.