|  | Home | Libraries | People | FAQ | More | 
boost::any — A class whose instances can hold instances of any type that satisfies ValueType requirements.
// In header: <boost/any.hpp> class any { public: // construct/copy/destruct any(); any(const any &); any(any &&); template<typename ValueType> any(const ValueType &); template<typename ValueType> any(ValueType &&); any & operator=(const any &); any & operator=(any &&); template<typename ValueType> any & operator=(const ValueType &); template<typename ValueType> any & operator=(ValueType &&); ~any(); // modifiers any & swap(any &); // queries bool empty() const; const std::type_info & type() const; };
any 
        public
       construct/copy/destructany();
| Postconditions: | this->empty() | 
any(const any & other);
| Effects: | Copy constructor that copies content of otherinto new instance, so that any content
            is equivalent in both type and value to the content ofother, or empty ifotheris
            empty. | 
| Throws: | May fail with a std::bad_allocexception or any exceptions arising from the copy
            constructor of the contained type. | 
any(any && other);
| Effects: | Move constructor that moves content of otherinto new instance and leavesotherempty. | 
| Postconditions: | other->empty() | 
| Throws: | Nothing. | 
template<typename ValueType> any(const ValueType & value);
| Effects: | Makes a copy of value, so
            that the initial content of the new instance is equivalent
            in both type and value tovalue. | 
| Throws: | std::bad_allocor any exceptions arising from the copy constructor of the
            contained type. | 
template<typename ValueType> any(ValueType && value);
| Effects: | Forwards value, so
            that the initial content of the new instance is equivalent
            in both type and value tovaluebefore the forward. | 
| Throws: | std::bad_allocor any exceptions arising from the copy constructor of the
            contained type. | 
any & operator=(const any & rhs);
| Effects: | Copies content of rhsinto
            current instance, discarding previous content, so that the
            new content is equivalent in both type and value to the
            content ofrhs, or empty ifrhs.empty(). | 
| Throws: | std::bad_allocor any exceptions arising from the copy constructor of the
            contained type. Assignment satisfies the strong guarantee
            of exception safety. | 
any & operator=(any && rhs);
template<typename ValueType> any & operator=(const ValueType & rhs);
| Effects: | Makes a copy of rhs,
            discarding previous content, so that the new content of is
            equivalent in both type and value torhs. | 
| Throws: | std::bad_allocor any exceptions arising from the copy constructor of the
            contained type. Assignment satisfies the strong guarantee
            of exception safety. | 
template<typename ValueType> any & operator=(ValueType && rhs);
| Effects: | Forwards rhs,
            discarding previous content, so that the new content of is
            equivalent in both type and value torhsbefore forward. | 
| Throws: | std::bad_allocor any exceptions arising from the move or copy constructor of the
            contained type. Assignment satisfies the strong guarantee
            of exception safety. | 
~any();
| Effects: | Releases any and all resources used in management of instance. | 
| Throws: | Nothing. | 
any queriesbool empty() const;
| Returns: | trueif instance is
              empty, otherwisefalse. | 
| Throws: | Nothing. | 
const std::type_info & type() const;
| Returns: | the typeidof the
              contained value if instance is non-empty, otherwisetypeid(void). | 
| Notes: | Useful for querying against types known either at compile time or only at runtime. |