次の方法で共有


any class

any オブジェクトにコンストラクターの要件を満たす型のインスタンスが格納されるか、値がないかのいずれかです。 格納されているインスタンスがある場合、または値がない場合は、any オブジェクトの "状態" と呼ばれます。

格納されたインスタンスは、含まれる値と呼ばれます。 2 つの any オブジェクトは、その両方に値がない場合、または両方に格納された値がありそれらの値が同じ場合、同じ状態になります。

構文

class any;

メンバー

コンストラクター

名前 説明
any any 型のオブジェクトを構築します。

関数

名前 説明
emplace any 値を設定します。
has_value any に値がある場合は true を返します。
reset any をリセットします。
swap 2 つの any オブジェクトを交換します。
type any 型を返します。

演算子

名前 説明
operator= any を別の any のコピーに置き換えます。

any

any 型のオブジェクトを構築します。 デストラクターも含まれています。

constexpr any() noexcept;
any(const any& other);
any(any&& other) noexcept;
template <class T>
    any(T&& value);
template <class T, class... Args>
    explicit any(in_place_type_t<T>, Args&&...);
template <class T, class U, class... Args>
    explicit any(in_place_type_t<T>, initializer_list<U>, Args&&...);

~any();

emplace

any 値を設定します。

template <class T, class... Args>
    decay_t<T>& emplace(Args&& ...);
template <class T, class U, class... Args>
    decay_t<T>& emplace(initializer_list<U>, Args&&...);

has_value

any オブジェクトに値がある場合は true を返します。

bool has_value() const noexcept;

operator=

any コンテンツを別の any のコピーに置き換えます。

any& operator=(const any& right);
any& operator=(any&& right) noexcept;
template <class T>
    any& operator=(T&& right);

パラメーター

right
この any にコピーされる any

reset

any をリセットします。

void reset() noexcept;

swap

2 つの any オブジェクトを交換します。

void swap(any& rhs) noexcept;

type

any 型を返します。

const type_info& type() const noexcept;

要件

ヘッダー:<any>

名前空間: std

標準: C++17 (コンパイルするには、少なくとも /std:c++17 を使用します。)

関連項目

<any>
any_cast
make_any
swap
bad_any_cast