WPILibC++ 2024.1.1-beta-4
Casting.h File Reference
#include "wpi/Compiler.h"
#include "wpi/type_traits.h"
#include <cassert>
#include <memory>
#include <optional>
#include <type_traits>

Go to the source code of this file.

Classes

struct  wpi::simplify_type< From >
 Define a template that can be specialized by smart pointers to reflect the fact that they are automatically dereferenced, and are not involved with the template selection process... the default implementation is a noop. More...
 
struct  wpi::simplify_type< const From >
 
struct  wpi::isa_impl< To, From, Enabler >
 
struct  wpi::isa_impl< To, From, std::enable_if_t< std::is_base_of_v< To, From > > >
 
struct  wpi::isa_impl_cl< To, From >
 
struct  wpi::isa_impl_cl< To, const From >
 
struct  wpi::isa_impl_cl< To, const std::unique_ptr< From > >
 
struct  wpi::isa_impl_cl< To, From * >
 
struct  wpi::isa_impl_cl< To, From *const >
 
struct  wpi::isa_impl_cl< To, const From * >
 
struct  wpi::isa_impl_cl< To, const From *const >
 
struct  wpi::isa_impl_wrap< To, From, SimpleFrom >
 
struct  wpi::isa_impl_wrap< To, FromTy, FromTy >
 
struct  wpi::cast_retty_impl< To, From >
 
struct  wpi::cast_retty_impl< To, const From >
 
struct  wpi::cast_retty_impl< To, From * >
 
struct  wpi::cast_retty_impl< To, const From * >
 
struct  wpi::cast_retty_impl< To, const From *const >
 
struct  wpi::cast_retty_impl< To, std::unique_ptr< From > >
 
struct  wpi::cast_retty_wrap< To, From, SimpleFrom >
 
struct  wpi::cast_retty_wrap< To, FromTy, FromTy >
 
struct  wpi::cast_retty< To, From >
 
struct  wpi::cast_convert_val< To, From, SimpleFrom >
 
struct  wpi::cast_convert_val< To, FromTy, FromTy >
 
struct  wpi::cast_convert_val< To, FromTy *, FromTy * >
 
struct  wpi::is_simple_type< X >
 
struct  wpi::CastIsPossible< To, From, Enable >
 This struct provides a way to check if a given cast is possible. More...
 
struct  wpi::CastIsPossible< To, std::optional< From > >
 
struct  wpi::CastIsPossible< To, From, std::enable_if_t< std::is_base_of_v< To, From > > >
 Upcasting (from derived to base) and casting from a type to itself should always be possible. More...
 
struct  wpi::NullableValueCastFailed< To >
 All of these cast traits are meant to be implementations for useful casts that users may want to use that are outside the standard behavior. More...
 
struct  wpi::DefaultDoCastIfPossible< To, From, Derived >
 This cast trait just provides the default implementation of doCastIfPossible to make CastInfo specializations more declarative. More...
 
struct  wpi::ValueFromPointerCast< To, From, Derived >
 This cast trait provides casting for the specific case of casting to a value-typed object from a pointer-typed object. More...
 
struct  wpi::UniquePtrCast< To, From, Derived >
 This cast trait provides std::unique_ptr casting. More...
 
struct  wpi::OptionalValueCast< To, From, Derived >
 This cast trait provides std::optional<T> casting. More...
 
struct  wpi::ConstStrippingForwardingCast< To, From, ForwardTo >
 Provides a cast trait that strips const from types to make it easier to implement a const-version of a non-const cast. More...
 
struct  wpi::ForwardToPointerCast< To, From, ForwardTo >
 Provides a cast trait that uses a defined pointer to pointer cast as a base for reference-to-reference casts. More...
 
struct  wpi::CastInfo< To, From, Enable >
 This struct provides a method for customizing the way a cast is performed. More...
 
struct  wpi::CastInfo< To, From, std::enable_if_t<!is_simple_type< From >::value > >
 This struct provides an overload for CastInfo where From has simplify_type defined. More...
 
struct  wpi::CastInfo< To, std::unique_ptr< From > >
 Provide a CastInfo specialized for std::unique_ptr. More...
 
struct  wpi::CastInfo< To, std::optional< From > >
 Provide a CastInfo specialized for std::optional<From>. More...
 
struct  wpi::ValueIsPresent< T, Enable >
 ValueIsPresent provides a way to check if a value is, well, present. More...
 
struct  wpi::ValueIsPresent< std::optional< T > >
 
struct  wpi::ValueIsPresent< T, std::enable_if_t< IsNullable< T > > >
 

Namespaces

namespace  wpi
 
namespace  wpi::detail
 

Typedefs

template<typename OptionalDerived , typename Default >
using wpi::detail::SelfType = std::conditional_t< std::is_same_v< OptionalDerived, void >, Default, OptionalDerived >
 A helper to derive the type to use with Self for cast traits, when the provided CRTP derived type is allowed to be void. More...
 

Functions

template<typename To , typename From >
bool wpi::isa (const From &Val)
 isa<X> - Return true if the parameter to the template is an instance of one of the template type arguments. More...
 
template<typename First , typename Second , typename... Rest, typename From >
bool wpi::isa (const From &Val)
 
template<typename To , typename From >
decltype(auto) wpi::cast (const From &Val)
 cast<X> - Return the argument parameter cast to the specified type. More...
 
template<typename To , typename From >
decltype(auto) wpi::cast (From &Val)
 
template<typename To , typename From >
decltype(auto) wpi::cast (From *Val)
 
template<typename To , typename From >
decltype(auto) wpi::cast (std::unique_ptr< From > &&Val)
 
template<typename T >
bool wpi::detail::isPresent (const T &t)
 
template<typename T >
decltype(auto) wpi::detail::unwrapValue (T &t)
 
template<typename To , typename From >
decltype(auto) wpi::dyn_cast (const From &Val)
 dyn_cast<X> - Return the argument parameter cast to the specified type. More...
 
template<typename To , typename From >
decltype(auto) wpi::dyn_cast (From &Val)
 
template<typename To , typename From >
decltype(auto) wpi::dyn_cast (From *Val)
 
template<typename To , typename From >
decltype(auto) wpi::dyn_cast (std::unique_ptr< From > &&Val)
 
template<typename... X, class Y >
bool wpi::isa_and_present (const Y &Val)
 isa_and_present<X> - Functionally identical to isa, except that a null value is accepted. More...
 
template<typename... X, class Y >
bool wpi::isa_and_nonnull (const Y &Val)
 
template<class X , class Y >
auto wpi::cast_if_present (const Y &Val)
 cast_if_present<X> - Functionally identical to cast, except that a null value is accepted. More...
 
template<class X , class Y >
auto wpi::cast_if_present (Y &Val)
 
template<class X , class Y >
auto wpi::cast_if_present (Y *Val)
 
template<class X , class Y >
auto wpi::cast_if_present (std::unique_ptr< Y > &&Val)
 
template<class X , class Y >
auto wpi::cast_or_null (const Y &Val)
 
template<class X , class Y >
auto wpi::cast_or_null (Y &Val)
 
template<class X , class Y >
auto wpi::cast_or_null (Y *Val)
 
template<class X , class Y >
auto wpi::cast_or_null (std::unique_ptr< Y > &&Val)
 
template<class X , class Y >
auto wpi::dyn_cast_if_present (const Y &Val)
 dyn_cast_if_present<X> - Functionally identical to dyn_cast, except that a null (or none in the case of optionals) value is accepted. More...
 
template<class X , class Y >
auto wpi::dyn_cast_if_present (Y &Val)
 
template<class X , class Y >
auto wpi::dyn_cast_if_present (Y *Val)
 
template<class X , class Y >
auto wpi::dyn_cast_or_null (const Y &Val)
 
template<class X , class Y >
auto wpi::dyn_cast_or_null (Y &Val)
 
template<class X , class Y >
auto wpi::dyn_cast_or_null (Y *Val)
 
template<class X , class Y >
CastInfo< X, std::unique_ptr< Y > >::CastResultType wpi::unique_dyn_cast (std::unique_ptr< Y > &Val)
 unique_dyn_cast<X> - Given a unique_ptr<Y>, try to return a unique_ptr<X>, taking ownership of the input pointer iff isa<X>(Val) is true. More...
 
template<class X , class Y >
auto wpi::unique_dyn_cast (std::unique_ptr< Y > &&Val)
 
template<class X , class Y >
CastInfo< X, std::unique_ptr< Y > >::CastResultType wpi::unique_dyn_cast_or_null (std::unique_ptr< Y > &Val)
 
template<class X , class Y >
auto wpi::unique_dyn_cast_or_null (std::unique_ptr< Y > &&Val)