![]() |
Home | Libraries | People | FAQ | More |
boost::anys::basic_any — A class with customizable Small Object Optimization whose instances can hold instances of any
type that satisfies ValueType
requirements. Use boost::any
instead if not sure.
// In header: <boost/any/basic_any.hpp> template< OptimizeForSize, OptimizeForAlignment> class basic_any { public: // construct/copy/destruct (); (basic_any &); (basic_any &&); template<typename ValueType> (); template<typename ValueType> (); basic_any & (basic_any &); basic_any & (basic_any &&); template<typename ValueType> basic_any & (); template<typename ValueType> basic_any & (); ~(); // modifiers basic_any & (basic_any &); // queries () ; std::type_info & () ; };
boost::anys::basic_any
is the drop-in replacement for
boost::any
that provides controll over Small Object
Optimization via OptimizeForSize
and OptimizeForAlignment
template
parameters.
There are certain applications that require boost::any
functionality, do know the typical/maximal size of the stored object and wish to avoid dynamic memory
allocation overhead. For the convenience such applications may create a typedef for basic_any
with the OptimizeForSize
and OptimizeForAlignment
template parameters set to
typical/maximal size and alignment of types respectively. Memory allocation would be avoided
for storing nothrow move constructible types with size and alignment less than or
equal to the OptimizeForSize
and OptimizeForAlignment
values.
Otherwise just use boost::any
.
basic_any
public
construct/copy/destruct();
Postconditions: |
this->empty() |
(basic_any & other);
Effects: |
Copy constructor that copies content of
other into new instance, so that any content
is equivalent in both type and value to the content of
other , or empty if other is
empty. |
Throws: |
May fail with a
std::bad_alloc
exception or any exceptions arising from the copy
constructor of the contained type. |
(basic_any && other);
Effects: |
Move constructor that moves content of
other into new instance and leaves other
empty. |
Postconditions: |
other->empty() |
Throws: |
Nothing. |
template<typename ValueType> ( value);
Effects: |
Makes a copy of Does not dynamically allocate if |
Throws: |
std::bad_alloc
or any exceptions arising from the copy constructor of the
contained type. |
template<typename ValueType> ( value);
Effects: |
Forwards Does not dynamically allocate if |
Throws: |
std::bad_alloc
or any exceptions arising from the move or copy constructor of the
contained type. |
basic_any & (basic_any & rhs);
Effects: |
Copies content of rhs into
current instance, discarding previous content, so that the
new content is equivalent in both type and value to the
content of rhs , or empty if
rhs.empty() . |
Throws: |
std::bad_alloc
or any exceptions arising from the copy constructor of the
contained type. Assignment satisfies the strong guarantee
of exception safety. |
basic_any & (basic_any && rhs);
template<typename ValueType> basic_any & ( rhs);
Effects: |
Makes a copy of Does not dynamically allocate if |
Throws: |
std::bad_alloc
or any exceptions arising from the copy constructor of the
contained type. Assignment satisfies the strong guarantee
of exception safety. |
template<typename ValueType> basic_any & ( rhs);
Effects: |
Forwards Does not dynamically allocate if |
Throws: |
std::bad_alloc
or any exceptions arising from the move or copy constructor of the
contained type. Assignment satisfies the strong guarantee
of exception safety. |
~();
Effects: |
Releases any and all resources used in management of instance. |
Throws: |
Nothing. |