[smart_ptr] !defined(BOOST_NO_CXX11_SMART_PTR) does not imply !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)

`!defined(BOOST_NO_CXX11_SMART_PTR)` does not necessarily mean that the compiler support of rvalue references is available. For example, when I use shared_ptr (on trunk) with clang + libc++ in a C++03 mode, I get warnings something like boost/smart_ptr/shared_ptr.hpp:556:51: warning: rvalue references are a C++11 extension [-Wc++11-extensions] shared_ptr & operator=( std::unique_ptr<Y, D> && r ) Regards, Michel

Michel Morin wrote:
`!defined(BOOST_NO_CXX11_SMART_PTR)` does not necessarily mean that the compiler support of rvalue references is available. For example,
How could the standard library have std::unique_ptr without the compiler supporting rvalue references?
when I use shared_ptr (on trunk) with clang + libc++ in a C++03 mode, I get warnings something like
boost/smart_ptr/shared_ptr.hpp:556:51: warning: rvalue references are a C++11 extension [-Wc++11-extensions] shared_ptr & operator=( std::unique_ptr<Y, D> && r )
Looks like rvalue references are available, but as an extension.

Peter Dimov wrote:
Michel Morin wrote:
`!defined(BOOST_NO_CXX11_SMART_PTR)` does not necessarily mean that the compiler support of rvalue references is available. For example,
How could the standard library have std::unique_ptr without the compiler supporting rvalue references?
Seems like libc++ uses rvalue-ref emulation: http://llvm.org/svn/llvm-project/libcxx/trunk/include/memory
when I use shared_ptr (on trunk) with clang + libc++ in a C++03 mode, I get warnings something like
boost/smart_ptr/shared_ptr.hpp:556:51: warning: rvalue references are a C++11 extension [-Wc++11-extensions] shared_ptr & operator=( std::unique_ptr<Y, D> && r )
Looks like rvalue references are available, but as an extension.
You're right. But compiling with -Werror or -pedantic-errors results in compilation errors. Also BOOST_NO_CXX11_RVALUE_REFERENCES is defined. Regards, Michel

On Feb 8, 2013, at 11:22 PM, Michel Morin <mimomorin@gmail.com> wrote:
Peter Dimov wrote:
Michel Morin wrote:
`!defined(BOOST_NO_CXX11_SMART_PTR)` does not necessarily mean that the compiler support of rvalue references is available. For example,
How could the standard library have std::unique_ptr without the compiler supporting rvalue references?
Seems like libc++ uses rvalue-ref emulation: http://llvm.org/svn/llvm-project/libcxx/trunk/include/memory
Yeah, but it isn't very good emulation. I don't recommend it. Howard

Howard Hinnant wrote:
How could the standard library have std::unique_ptr without the compiler supporting rvalue references?
Seems like libc++ uses rvalue-ref emulation: http://llvm.org/svn/llvm-project/libcxx/trunk/include/memory
Yeah, but it isn't very good emulation. I don't recommend it.
Thanks for the info, Howard. Actually, I didn't use std::unique_ptr in a C++03 mode, but I just included <boost/smart_ptr/shared_ptr.hpp> #include <boost/smart_ptr/shared_ptr.hpp> int main(int argc, char* argv[]) { return 0; } This gives me warnings about rvalue references used in <boost/smart_ptr/shared_ptr.hpp>. So I'd be happy if #if !defined( BOOST_NO_CXX11_SMART_PTR ) will be changed to #if !defined( BOOST_NO_CXX11_SMART_PTR ) \ && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) Another solution might be defining BOOST_NO_CXX11_SMART_PTR in Boost.Config for libc++. Regards, Michel
participants (3)
-
Howard Hinnant
-
Michel Morin
-
Peter Dimov