Home | Libraries | People | FAQ | More |
boost::reference_wrapper —
Contains a reference to an object of type
T
.
// In header: <boost/ref.hpp> template<typename T> class reference_wrapper { public: // types typedef T type; // construct/copy/destruct explicit reference_wrapper(T&); // access operator T&() const; T& get() const; T* get_pointer() const; }; // constructors reference_wrapper<T> ref(T&); reference_wrapper<T const> cref(T const&); // access unwrap_reference<T>::type& unwrap_ref(T&);
reference_wrapper
is primarily used to "feed" references to function templates
(algorithms) that take their parameter by value. It provides
an implicit conversion to
T&
, which usually allows
the function templates to work on references
unmodified.
reference_wrapper
public
construct/copy/destructexplicit reference_wrapper(T& t);
Effects: |
Constructs a
reference_wrapper
object that stores a reference to
t . |
Throws: |
Does not throw. |
reference_wrapper
constructorsreference_wrapper<T> ref(T& t);
Returns: |
reference_wrapper<T>(t) |
Throws: |
Does not throw. |
reference_wrapper<T const> cref(T const& t);
Returns: |
reference_wrapper<T const>(t) |
Throws: |
Does not throw. |
reference_wrapper
accessunwrap_reference<T>::type& unwrap_ref(T& t);
Returns: |
unwrap_reference<T>::type&(t) |
Throws: |
Does not throw. |