Namespaces
Variants

Standard library header <any> (C++17)

From cppreference.net
Standard library headers

このヘッダは 汎用ユーティリティ ライブラリの一部です。

目次

クラス

(C++17)
CopyConstructible な型のインスタンスを保持するオブジェクト
(クラス)
型不一致時に any_cast の値返却形式によって送出される例外
(クラス)

関数

std::swap アルゴリズムの特殊化
(関数)
(C++17)
any オブジェクトを作成する
(関数テンプレート)
(C++17)
包含されたオブジェクトへの型安全なアクセス
(関数テンプレート)

概要

namespace std {
  // クラス bad_any_cast
  class bad_any_cast;
  // クラス any
  class any;
  // 非メンバ関数
  void swap(any& x, any& y) noexcept;
  template<class T, class... Args>
    any make_any(Args&&... args);
  template<class T, class U, class... Args>
    any make_any(initializer_list<U> il, Args&&... args);
  template<class T>
    T any_cast(const any& operand);
  template<class T>
    T any_cast(any& operand);
  template<class T>
    T any_cast(any&& operand);
  template<class T>
    const T* any_cast(const any* operand) noexcept;
  template<class T>
    T* any_cast(any* operand) noexcept;
}

クラス std::bad_any_cast

namespace std {
  class bad_any_cast : public bad_cast {
  public:
    // [例外] の特殊メンバ関数の仕様を参照
    const char* what() const noexcept override;
  };
}

クラス std::any

namespace std {
  class any {
  public:
    // 構築と破棄
    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();
    // 代入
    any& operator=(const any& rhs);
    any& operator=(any&& rhs) noexcept;
    template<class T>
      any& operator=(T&& rhs);
    // 変更操作
    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&&...);
    void reset() noexcept;
    void swap(any& rhs) noexcept;
    // 観測
    bool has_value() const noexcept;
    const type_info& type() const noexcept;
  };
}