Audacity 3.2.0
Classes | Public Member Functions | Private Attributes | List of all members
audacity::TypedAny< Tag > Class Template Reference

Generates distinct, non-interconvertible types wrapping std::any. More...

#include <TypedAny.h>

Inheritance diagram for audacity::TypedAny< Tag >:
[legend]

Classes

struct  Good_args
 
struct  Good_args< Arg >
 

Public Member Functions

template<typename... Args, typename restriction = std::enable_if_t< Good_args<Args...>::value >>
 TypedAny (Args &&... args)
 Constructor with arguments just as for std::any, but it is explicit. More...
 
 TypedAny (const TypedAny &)=default
 
TypedAnyoperator= (const TypedAny &)=default
 
 TypedAny (TypedAny &&)=default
 
TypedAnyoperator= (TypedAny &&)=default
 

Private Attributes

std::any mAny
 

Pass-through member functions

Supply an imitation of std::any's interface, except for reference-valued any_cast

template<typename ValueType , typename... Args>
std::decay_t< ValueType > & emplace (Args &&... args)
 
void reset () noexcept
 
void swap (TypedAny &other) noexcept
 
bool has_value () const noexcept
 
const std::type_info & type () const noexcept
 
template<typename T >
const T * cast () const noexcept
 Like pointer-valued any_cast but a non-static member function. More...
 
template<typename T >
T * cast () noexcept
 Like pointer-valued any_cast but a non-static member function. More...
 
template<typename T , typename... Args>
static TypedAny make (Args &&... args)
 Like make_any but a static member function. More...
 

Detailed Description

template<typename Tag>
class audacity::TypedAny< Tag >

Generates distinct, non-interconvertible types wrapping std::any.

Template Parameters
Tagdiscriminates generated classes; a "CRTP" parameter

Definition at line 24 of file TypedAny.h.

Constructor & Destructor Documentation

◆ TypedAny() [1/3]

template<typename Tag >
template<typename... Args, typename restriction = std::enable_if_t< Good_args<Args...>::value >>
audacity::TypedAny< Tag >::TypedAny ( Args &&...  args)
inlineexplicit

Constructor with arguments just as for std::any, but it is explicit.

Definition at line 39 of file TypedAny.h.

40 : mAny(std::forward<Args>(args)...)
41 {}
std::any mAny
Definition: TypedAny.h:84

References forward.

Referenced by audacity::TypedAny< Tag >::make().

Here is the caller graph for this function:

◆ TypedAny() [2/3]

template<typename Tag >
audacity::TypedAny< Tag >::TypedAny ( const TypedAny< Tag > &  )
default

◆ TypedAny() [3/3]

template<typename Tag >
audacity::TypedAny< Tag >::TypedAny ( TypedAny< Tag > &&  )
default

Member Function Documentation

◆ cast() [1/2]

template<typename Tag >
template<typename T >
const T * audacity::TypedAny< Tag >::cast ( ) const
inlinenoexcept

Like pointer-valued any_cast but a non-static member function.

Definition at line 68 of file TypedAny.h.

68{ return std::any_cast<T>(&mAny); }

References audacity::TypedAny< Tag >::mAny.

Referenced by EffectSettings::Copy().

Here is the caller graph for this function:

◆ cast() [2/2]

template<typename Tag >
template<typename T >
T * audacity::TypedAny< Tag >::cast ( )
inlinenoexcept

Like pointer-valued any_cast but a non-static member function.

Definition at line 72 of file TypedAny.h.

72{ return std::any_cast<T>(&mAny); }

References audacity::TypedAny< Tag >::mAny.

◆ emplace()

template<typename Tag >
template<typename ValueType , typename... Args>
std::decay_t< ValueType > & audacity::TypedAny< Tag >::emplace ( Args &&...  args)
inline

Definition at line 57 of file TypedAny.h.

58 {
59 return mAny.emplace<ValueType>(std::forward<Args>(args)...);
60 }

References audacity::TypedAny< Tag >::mAny.

◆ has_value()

template<typename Tag >
bool audacity::TypedAny< Tag >::has_value ( ) const
inlinenoexcept

Definition at line 63 of file TypedAny.h.

63{ return mAny.has_value(); }

References audacity::TypedAny< Tag >::mAny.

◆ make()

template<typename Tag >
template<typename T , typename... Args>
static TypedAny audacity::TypedAny< Tag >::make ( Args &&...  args)
inlinestatic

Like make_any but a static member function.

Definition at line 76 of file TypedAny.h.

77 {
78 return TypedAny(std::in_place_type<T>, std::forward<Args>(args)...);
79 }
TypedAny(Args &&... args)
Constructor with arguments just as for std::any, but it is explicit.
Definition: TypedAny.h:39

References audacity::TypedAny< Tag >::TypedAny().

Here is the call graph for this function:

◆ operator=() [1/2]

template<typename Tag >
TypedAny & audacity::TypedAny< Tag >::operator= ( const TypedAny< Tag > &  )
default

◆ operator=() [2/2]

template<typename Tag >
TypedAny & audacity::TypedAny< Tag >::operator= ( TypedAny< Tag > &&  )
default

◆ reset()

template<typename Tag >
void audacity::TypedAny< Tag >::reset ( )
inlinenoexcept

Definition at line 61 of file TypedAny.h.

61{ mAny.reset(); }

References audacity::TypedAny< Tag >::mAny.

◆ swap()

template<typename Tag >
void audacity::TypedAny< Tag >::swap ( TypedAny< Tag > &  other)
inlinenoexcept

Definition at line 62 of file TypedAny.h.

62{ mAny.swap(other.mAny); }

References audacity::TypedAny< Tag >::mAny.

Referenced by audacity::swap().

Here is the caller graph for this function:

◆ type()

template<typename Tag >
const std::type_info & audacity::TypedAny< Tag >::type ( ) const
inlinenoexcept

Definition at line 64 of file TypedAny.h.

64{ return mAny.type(); }

References audacity::TypedAny< Tag >::mAny.

Member Data Documentation

◆ mAny

template<typename Tag >
std::any audacity::TypedAny< Tag >::mAny
private

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