Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-12-15 11:39:55


Douglas Gregor <gregod_at_[hidden]> writes:

> On Sunday 15 December 2002 10:58 am, David Abrahams wrote:
>> I just noticed I have the following in
>> boost/python/object/forward.hpp:
>>
>> // Very much like boost::reference_wrapper<T>, except that in this
>> // case T can be a reference already without causing a
>> // reference-to-reference error.
>> template <class T>
>> struct reference_to_value
>> {
>> typedef typename add_reference<typename add_const<T>::type>::type
>> reference;
>>
>> reference_to_value(reference x) : m_value(x) {}
>> operator reference() const { return m_value; }
>> private:
>> reference m_value;
>> };
>>
>> It strikes me that I might be able to replace this with
>> reference_wrapper if it just did the same little add_reference<T>
>> trick itself (I can handle the const externally). If you look further
>> down in that file you'll see there's now logic for unwrapping
>> something which might either be reference_wrapper _or_
>> reference_to_value, so it could be a major win.
>>
>> Any thoughts/objections/whatever?
>>
>> -Dave
>
> Good idea so long as reference_wrapper stays Assignable.

Why would it not be assignable?

> Is remove_reference implemented on all compilers?

Of course not, it needs PTS! But I don't see the relationship
here. I'm not doing remove_reference.

> If so, I have no objections.

I'm confused. Either you misunderstood my suggestion or you're seeing
some deeper problem that I've missed.

-- 
                       David Abrahams
   dave_at_[hidden] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk