Boost logo

Boost :

Subject: Re: [boost] Fwd: Re: [move] You can do it better: implementing push_back and handling implicit conversions
From: Jeffrey Lee Hellrung, Jr. (jhellrung_at_[hidden])
Date: 2011-03-09 17:02:53


On 3/9/2011 1:41 PM, Ion Gaztañaga wrote:
> El 09/03/2011 21:32, Jeffrey Lee Hellrung, Jr. escribió:
>> By "should fail", you mean "should fail to compile, according to the
>> standard", and here "value" is not an object of the std::list
>> value_type, but some other type that's convertible to value_type,
>> correct? Again, just to clarify.
>
> Right. The idea is also to have some macro to ease writing the same code
> for both C++03 and C++0x, e.g., priv_push_back receives a BOOST_FWD_REF
> param that can be forwarded both in C++03 and C++0x.

It seems reasonable for priv_push_back to have a common implementation
between C++03 and C++0x. I believe the C++03 version should probably
take it's parameter as U& rather than U const &, to preserve constness,
so you might need to add an additional forwarding reference macro. I
think I suggested this also in the Boost.Move review discussion. My
lack of creativity has me using FWD2_REF( U ) expanding to U& in C++03
and U&& in C++0x.

Are you also aiming to use macros to generate the various push_back
overloads as well? That could be challenging to design a reasonable
interface for, and I'm not necessarily opposed to the #ifndef
BOOST_NO_RVALUE_REFERENCES / #else / #endif (as I'm not sure if a macro
solution would look any better).

- Jeff


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