W3cubDocs

/C++

Standard library header <any>

This header is part of the general utility library.

Classes

Name Description
(since C++17)
Objects that hold instances of any CopyConstructible type.
(class)
(C++17)
exception thrown by the value-returning forms of any_cast on a type mismatch
(class)

Functions

specializes the std::swap algorithm
(function)
(C++17)
type-safe access to the contained object
(function template)

Synopsis

namespace std {
 
  class bad_any_cast : public bad_cast
  {
  public:
    virtual const char* what() const noexcept;
  };
 
  class any
  {
  public:
    // any construct/destruct
    any() noexcept;
 
    any(const any& other);
    any(any&& x) noexcept;
 
    template <class ValueType>
        any(ValueType&& value);
 
    ~any();
 
    // any assignments
    any& operator=(const any& rhs);
    any& operator=(any&& rhs) noexcept;
 
    template <class ValueType>
      any& operator=(ValueType&& rhs);
 
    // any modifiers
    void clear() noexcept;
    void swap(any& rhs) noexcept;
 
    // any observers
    bool empty() const noexcept;
    const type_info& type() const noexcept;
  };
 
  // Non-member functions
  void swap(any& x, any& y) noexcept;
 
  template<class ValueType>
    ValueType any_cast(const any& operand);
  template<class ValueType>
    ValueType any_cast(any& operand);
  template<class ValueType>
    ValueType any_cast(any&& operand);
 
  template<class ValueType>
    const ValueType* any_cast(const any* operand) noexcept;
  template<class ValueType>
    ValueType* any_cast(any* operand) noexcept;
 
} // namespace std

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/header/any