Boost logo

Boost Users :

Subject: Re: [Boost-users] [container / move] return a container of non-movables from a function in C++03
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-08-13 17:03:51


Le 13/08/13 16:09, Adam Romanek a écrit :
> Hi,
>
> I'd like to return a container of non-movables from a function in
> C++03 with no success.
>
Boost.Container should be movable independently on whether their
elements are movable or not.
> here is a sample code that does not compile for me:
>
> #include <boost/container/vector.hpp>
> #include <boost/move/utility.hpp>
>
> class non_copyable {
> BOOST_MOVABLE_BUT_NOT_COPYABLE(non_copyable)
>
> public:
> non_copyable(){}
> non_copyable(BOOST_RV_REF(non_copyable)) {}
> non_copyable& operator=(BOOST_RV_REF(non_copyable)) { return *this; }
> };
>
> typedef boost::container::vector<non_copyable> nc_vector;
>
> nc_vector create() {
> return nc_vector();
> }
>
I suspect that this is a limitation on the emulation with gcc-4.6.3.
Could you try

nc_vector create() {
   nc_vector res;
   return boost::move(res);
}

Best,
Vicente


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net