3.0.0
Freundlich's C++ toolkit
Classes | Typedefs | Functions
fcppt::cast Namespace Reference

Cast helpers which provide more type information or do additional checks. More...

Classes

class  bad_dynamic
 May be thrown by fcppt::cast::dynamic if the cast fails. More...
 
class  bad_truncation_check
 May be thrown by fcppt::cast::truncation_check if the conversion truncates. More...
 
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. More...
 

Functions

template<typename Fun , typename Res , typename Src >
decltype(auto) constexpr apply (Src &&_src)
 Applies a cast to a source. More...
 
template<typename Derived , typename Base >
fcppt::optional::reference< Derived > dynamic (Base &_base) noexcept
 Converts between references of related types using dynamic_cast, returning an empty optional on failure. More...
 
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. More...
 
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. More...
 
template<typename Dest , typename Src >
std::enable_if_t< std::is_reference< Dest >::value, Dest > dynamic_cross_exn (Src &_src)
 Converts between references of unrelated types using dynamic_cast and provides additional error information. More...
 
template<typename Derived , typename Base >
std::enable_if_t< std::is_reference< Derived >::value, Derived > dynamic_exn (Base &_src)
 Converts between references of related types using dynamic_cast and provides additional error information. More...
 
template<typename Dest , typename Enum >
constexpr Dest enum_to_int (Enum const _enum) noexcept
 Converts an enum to an int. More...
 
template<typename Enum >
constexpr std::underlying_type_t< Enum > enum_to_underlying (Enum const _enum) noexcept
 Converts an enum to its underlying type. More...
 
template<typename Dest , typename Source >
constexpr Dest float_to_int (Source const _source) noexcept
 Converts a float to a signed int. More...
 
template<typename Dest , typename Source >
Dest from_void_ptr (Source *const _ptr) noexcept
 Converts a void pointer to a different pointer. More...
 
template<typename Enum , typename Source >
constexpr Enum int_to_enum (Source const _source) noexcept
 Converts an int to an enum. More...
 
template<typename Dest , typename Source >
constexpr Dest int_to_float (Source const _source) noexcept
 Converts an int to a float. More...
 
template<typename Type >
constexpr fcppt::cast::promote_int_type< Type > promote_int (Type const &_value)
 Promotes an integral type to int or unsigned int. More...
 
template<typename Dest , typename Source >
constexpr Dest safe (Source const &_source)
 A cast that prohibits lossy conversions. More...
 
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. More...
 
template<typename Dest , typename Source >
constexpr Dest size (Source const _source) noexcept
 Converts a type to a similar type of different size. More...
 
template<typename Derived , typename Base >
std::enable_if_t< std::is_reference< Derived >::value, Derived > static_downcast (Base &_source) noexcept
 Statically converts a reference to a base class to a reference to a derived class. More...
 
template<typename Dest , typename Source >
Dest to_char_ptr (Source *const _source) noexcept
 Converts a pointer to a pointer to characters. More...
 
template<typename Type >
constexpr std::make_signed_t< Type > to_signed (Type const _value) noexcept
 Converts an unsigned int to its signed type. More...
 
template<typename Source >
std::uintptr_t to_uint_ptr (Source *const _ptr) noexcept
 Converts a pointer to a std::uintptr_t. More...
 
template<typename Type >
constexpr std::make_unsigned_t< Type > to_unsigned (Type const _value) noexcept
 Converts a signed int to its unsigned type. More...
 
template<typename Type >
void to_void (Type const &_value) noexcept
 Casts an expression to void. More...
 
template<typename Source >
void const * to_void_ptr (Source const *const _ptr) noexcept
 Converts a pointer to const to a pointer to const void. More...
 
template<typename Source >
void * to_void_ptr (Source *const _ptr) noexcept
 Converts a pointer to a pointer to void. More...
 
template<typename Dest , typename Source >
Dest truncation_check (Source const _source)
 Cast between integral types, checking for truncation. More...
 

Detailed Description

Cast helpers which provide more type information or do additional checks.