[libcxx-commits] [PATCH] D67524: P1144 "Trivially relocatable" (3/3): optimize std::vector for trivially relocatable types

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Sep 13 09:38:52 PDT 2019


zoecarver added inline comments.


================
Comment at: include/vector:479
+    __has_trivial_construct<_Allocator, _Tp,
+#ifndef _LIBCPP_CXX03_LANG
+        _Tp&&
----------------
Quuxplusone wrote:
> zoecarver wrote:
> > We don't need to do this anymore! Every compiler that we support supports rvalues (I think).
> I think you're right, but then I'm confused by the similar code on the return type of `move_if_noexcept` (in trunk). What does `_Tp&&` mean, in C++03 mode? Is it a synonym for `const _Tp&`? If so, why does `move_if_noexcept` need that ifndef?
> 
> ```
> template <class _Tp>
> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
> #ifndef _LIBCPP_CXX03_LANG
> typename conditional
> <
>     !is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value,
>     const _Tp&,
>     _Tp&&
> >::type
> #else  // _LIBCPP_CXX03_LANG
> const _Tp&
> #endif
> move_if_noexcept(_Tp& __x) _NOEXCEPT
> {
>     return _VSTD::move(__x);
> }
> ```
Clang supports rvalues in C++03 mode. So it will work just like in C++11 mode. `move_if_noexcept` probably just hasn't been updated. Example: https://godbolt.org/z/L2CJQa


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67524/new/

https://reviews.llvm.org/D67524





More information about the libcxx-commits mailing list