Standard library header <experimental/any> - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# Standard library header <experimental/any>

From cppreference.com
< cpp‎ | header

This header is part of the experimental library.

### [edit] Classes

Name | Description
std::experimental::bad_any_cast (library fundamentals TS) | Objects of type `bad_any_cast` are thrown by a failed `any_cast`. (class)
std::experimental::any (library fundamentals TS) | Objects of class `any` hold instances of any type that satisfies the `ValueType` requirements. (class)

### [edit] Functions

swap | swaps two `any` instances (function) [edit]
any_cast | type-safe access to the contained object (function template) [edit]

### [edit] Synopsis

    namespace std {
    namespace experimental {
    inline namespace fundamentals_v1 {

      class bad_any_cast : public bad_cast
      {
      public:
        virtual const char* what() const noexcept;
      };

      class any
      {
      public:
        // 6.3.1, any construct/destruct
        any() noexcept;

        any(const any& other);
        any(any&& x) noexcept;

        template <class ValueType>
            any(ValueType&& value);

        template <class Allocator>
            any(allocator_arg_t, const Allocator& a) noexcept;
        template <class Allocator, class ValueType>
            any(allocator_arg_t, const Allocator& a, ValueType&& value);
        template <class Allocator>
            any(allocator_arg_t, const Allocator& a, const any& other);
        template <class Allocator>
            any(allocator_arg_t, const Allocator& a, any&& other) noexcept;

        ~any();

        // 6.3.2, any assignments
        any& operator=(const any& rhs);
        any& operator=(any&& rhs) noexcept;

        template <class ValueType>
          any& operator=(ValueType&& rhs);

        // 6.3.3, any modifiers
        void clear() noexcept;
        void swap(any& rhs) noexcept;

        // 6.3.4, any observers
        bool empty() const noexcept;
        const type_info& type() const noexcept;
      };

      // 6.4, 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 fundamentals_v1
    } // namespace experimental
    } // namespace std

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/header/experimental/any&oldid=71489"