Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-01-23 12:50:15

I propose a very simple patch to ref.hpp which allows one to portably
determine whether a type is a reference_wrapper, and to extract its "value

namespace detail
  struct reference_wrapper_base {};
template<class T> class reference_wrapper
        : public detail::reference_wrapper_base
    typedef T value_type;
    explicit reference_wrapper(T & t): t_(t) {}
    operator T & () const { return t_; }
    T & get() const { return t_; }
    T & t_;
    reference_wrapper & operator= (reference_wrapper const &);
There's a bunch of other code needed to make this useful, but it introduces a dependency on type_traits in the no-partial-spec. case, so I guess that should go in a separate file.
I happen to need something exactly like this for Boost.Python. Thoughts?
  David Abrahams, C++ library designer for hire
        C++ Booster ( 
          email: david.abrahams_at_[hidden]

Boost list run by bdawes at, gregod at, cpdaniel at, john at