
2012/7/16 Ion Gaztañaga
El 16/07/2012 13:54, Krzysztof Czainski escribió:
Version 1: C++03 vs. C++0x:
- the last 4 use cases {{{ ptr<A> b = make_b(); ptr<A> c( make_b() ); a = make_a(); b = make_b(); }}} introduce a deep copy in version C++03, while while the deep copy is avoided in C++0x.
Thanks for the report. It's a pity that current move emulation does not catch rvalues of convertible types to avoid the copy. Maybe for the last two cases you could try with BOOST_COPY_ASSIGN_REF(ptr<U>) to see if the deep copy is avoided.
Best,
Ion
Thanks for the suggestion, Ion. I had tried that before, but it caused
compiler errors. Replacing one line
operator=( ptr<U> const& b )
with
operator=( BOOST_COPY_ASSIGN_REF(ptr<U>) b )
results in compiler errors:
..\main.cpp:76:9: error: no match for 'operator=' in 'x = h'
..\/ptr.hpp:53:5: note: candidates are: ptr<T>& ptr<T>::operator=(ptr<T>&)
[with T = A, ptr<T> = ptr<A>]
..\/ptr.hpp:69:10: note: ptr<T>& ptr<T>::operator=(const
boost::rv