LLVM 20.0.0git
Public Types | Static Public Member Functions | List of all members
llvm::ConstStrippingForwardingCast< To, From, ForwardTo > Struct Template Reference

Provides a cast trait that strips const from types to make it easier to implement a const-version of a non-const cast. More...

#include "llvm/Support/Casting.h"

Inheritance diagram for llvm::ConstStrippingForwardingCast< To, From, ForwardTo >:
Inheritance graph
[legend]

Public Types

using DecayedFrom = std::remove_cv_t< std::remove_pointer_t< From > >
 
using NonConstFrom = std::conditional_t< std::is_pointer_v< From >, DecayedFrom *, DecayedFrom & >
 

Static Public Member Functions

static bool isPossible (const From &f)
 
static decltype(auto) castFailed ()
 
static decltype(auto) doCast (const From &f)
 
static decltype(auto) doCastIfPossible (const From &f)
 

Detailed Description

template<typename To, typename From, typename ForwardTo>
struct llvm::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.

It just removes boilerplate and reduces the amount of code you as the user need to implement. You can use it like this:

template<> struct CastInfo<foo, bar> { ...verbose implementation... };

template<> struct CastInfo<foo, const bar> : public ConstStrippingForwardingCast<foo, const bar, CastInfo<foo, bar>> {};

Definition at line 388 of file Casting.h.

Member Typedef Documentation

◆ DecayedFrom

template<typename To , typename From , typename ForwardTo >
using llvm::ConstStrippingForwardingCast< To, From, ForwardTo >::DecayedFrom = std::remove_cv_t<std::remove_pointer_t<From> >

Definition at line 390 of file Casting.h.

◆ NonConstFrom

template<typename To , typename From , typename ForwardTo >
using llvm::ConstStrippingForwardingCast< To, From, ForwardTo >::NonConstFrom = std::conditional_t<std::is_pointer_v<From>, DecayedFrom *, DecayedFrom &>

Definition at line 392 of file Casting.h.

Member Function Documentation

◆ castFailed()

template<typename To , typename From , typename ForwardTo >
static decltype(auto) llvm::ConstStrippingForwardingCast< To, From, ForwardTo >::castFailed ( )
inlinestatic

Definition at line 399 of file Casting.h.

◆ doCast()

template<typename To , typename From , typename ForwardTo >
static decltype(auto) llvm::ConstStrippingForwardingCast< To, From, ForwardTo >::doCast ( const From f)
inlinestatic

Definition at line 401 of file Casting.h.

◆ doCastIfPossible()

template<typename To , typename From , typename ForwardTo >
static decltype(auto) llvm::ConstStrippingForwardingCast< To, From, ForwardTo >::doCastIfPossible ( const From f)
inlinestatic

Definition at line 405 of file Casting.h.

◆ isPossible()

template<typename To , typename From , typename ForwardTo >
static bool llvm::ConstStrippingForwardingCast< To, From, ForwardTo >::isPossible ( const From f)
inlinestatic

Definition at line 395 of file Casting.h.


The documentation for this struct was generated from the following file: