$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
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
type":
----
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
namespace detail
{
struct reference_wrapper_base {};
}
#endif
template<class T> class reference_wrapper
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
: public detail::reference_wrapper_base
#endif
{
public:
typedef T value_type;
explicit reference_wrapper(T & t): t_(t) {}
operator T & () const { return t_; }
T & get() const { return t_; }
private:
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?
-Dave
===================================================
David Abrahams, C++ library designer for hire
resume: http://users.rcn.com/abrahams/resume.html
C++ Booster (http://www.boost.org)
email: david.abrahams_at_[hidden]
===================================================