Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class unique_any

boost::anys::unique_any — A class whose instances can hold instances of any type (including non-copyable and non-movable types).

Synopsis

// In header: <boost/any/unique_any.hpp>


class unique_any {
public:
  // construct/copy/destruct
  ();
  (unique_any &&);
  template<typename T> 
    (, 
               boost::any && >:: = );
  template<typename BoostAny> 
    (, 
               boost::any && >:: = ) ;
  template<typename T,  Args> 
    (in_place_type_t< , );
  template<typename T, typename U,  Args> 
    (in_place_type_t< , , 
                        );
  unique_any & (unique_any &&);
  template<typename T> unique_any & ();
  ~();

  // public member functions
  template<typename T,  Args> 
     ();
  template<typename T, typename U,  Args> 
     (, );
   () ;
   (unique_any &) ;
   () ;
   () ;
};

Description

unique_any public construct/copy/destruct

  1. ();

    Postconditions:

    this->has_value() is false.

  2. (unique_any && other);

    Move constructor that moves content of other into new instance and leaves other empty.

    Postconditions:

    other->has_value() is false.

    Throws:

    Nothing.
  3. template<typename T> 
      ( value, 
                 boost::any && >:: = );

    Forwards value, so that the content of the new instance has type std::decay_t<T> and value is the value before the forward.

    Throws:

    std::bad_alloc or any exceptions arising from the move or copy constructor of the contained type.
  4. template<typename BoostAny> 
      ( value, 
                 boost::any && >:: = ) ;

    Moves the content of boost::any into *this.

    Postconditions:

    value.empty() is true.

    Throws:

    Nothing.
  5. template<typename T,  Args> 
      (in_place_type_t< ,  args);

    Inplace constructs T from forwarded args..., so that the content of *this is equivalent in type to std::decay_t<T>.

    Throws:

    std::bad_alloc or any exceptions arising from the move or copy constructor of the contained type.
  6. template<typename T, typename U,  Args> 
      (in_place_type_t< ,  il, 
                           args);

    Inplace constructs T from li and forwarded args..., so that the initial content of *this is equivalent in type to std::decay_t<T>.

    Throws:

    std::bad_alloc or any exceptions arising from the move or copy constructor of the contained type.
  7. unique_any & (unique_any && rhs);

    Moves 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 before move, or empty if rhs.empty().

    Postconditions:

    rhs->empty() is true

    Throws:

    Nothing.
  8. template<typename T> unique_any & ( rhs);

    Forwards rhs, discarding previous content, so that the new content of is equivalent in both type and value to rhs before forward.

    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.
  9. ~();

    Releases any and all resources used in management of instance.

    Throws:

    Nothing.

unique_any public member functions

  1. template<typename T,  Args> 
       ( args);

    Inplace constructs T from forwarded args..., discarding previous content, so that the content of *this is equivalent in type to std::decay_t<T>.

    Returns:

    reference to the content of *this.

    Throws:

    std::bad_alloc or any exceptions arising from the move or copy constructor of the contained type.
  2. template<typename T, typename U,  Args> 
       
      ( il,  args);

    Inplace constructs T from li and forwarded args..., discarding previous content, so that the content of *this is equivalent in type to std::decay_t<T>.

    Returns:

    reference to the content of *this.

    Throws:

    std::bad_alloc or any exceptions arising from the move or copy constructor of the contained type.
  3.  () ;

    Postconditions:

    this->has_value() is false.

  4.  (unique_any & rhs) ;

    Exchange of the contents of *this and rhs.

    Returns:

    *this

    Throws:

    Nothing.
  5.  () ;

    Returns:

    true if instance is not empty, otherwise false.

    Throws:

    Nothing.
  6.  () ;

    Useful for querying against types known either at compile time or only at runtime.

    Returns:

    the typeid of the contained value if instance is non-empty, otherwise typeid(void).


PrevUpHomeNext