11#ifndef __AUDACITY_TYPED_ANY__
12#define __AUDACITY_TYPED_ANY__
28 template<
typename... Args>
struct Good_args : std::true_type{};
31 : std::bool_constant< !std::is_base_of_v<TypedAny,
32 std::remove_const_t< std::remove_reference_t<Arg> >
36 template<
typename... Args,
37 typename restriction = std::enable_if_t<
Good_args<Args...>::value >
56 template<
typename ValueType,
typename... Args>
57 std::decay_t<ValueType> &
emplace(Args &&... args)
64 const std::type_info&
type() const noexcept {
return mAny.type(); }
68 const T*
cast() const noexcept {
return std::any_cast<T>(&
mAny); }
72 T*
cast() noexcept {
return std::any_cast<T>(&
mAny); }
75 template<
typename T,
typename... Args>
78 return TypedAny(std::in_place_type<T>, std::forward<Args>(args)...);
Generates distinct, non-interconvertible types wrapping std::any.
TypedAny(TypedAny &&)=default
TypedAny & operator=(TypedAny &&)=default
T * cast() noexcept
Like pointer-valued any_cast but a non-static member function.
TypedAny(Args &&... args)
Constructor with arguments just as for std::any, but it is explicit.
std::decay_t< ValueType > & emplace(Args &&... args)
bool has_value() const noexcept
void swap(TypedAny &other) noexcept
const T * cast() const noexcept
Like pointer-valued any_cast but a non-static member function.
const std::type_info & type() const noexcept
TypedAny(const TypedAny &)=default
TypedAny & operator=(const TypedAny &)=default
static TypedAny make(Args &&... args)
Like make_any but a static member function.
void swap(TypedAny< Tag > &x, TypedAny< Tag > &y)
Non-member swap.