[libcxx-commits] [PATCH] D133013: [libc++] Enable rvalue overloads for pair in C++03
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Sep 2 08:47:04 PDT 2022
ldionne accepted this revision.
ldionne added inline comments.
This revision is now accepted and ready to land.
================
Comment at: libcxx/include/__utility/pair.h:424-445
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _T1, class _T2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>
make_pair(_T1&& __t1, _T2&& __t2)
{
----------------
huixie90 wrote:
> I guess this somehow changed the c++ 03 behaviour. it used to make copies on 1. function parameters 2. constructor initialisers
> Now it only make the copy inside constructors. Is it ok to make this change?
I was going to say this:
I don't think it is, actually, because in C++03 `make_pair` is explicitly specified like
```
template< class T1, class T2 >
std::pair<T1,T2> make_pair( T1 t, T2 u );
```
IMO the rest of these changes are OK, but this one does changes our C++03 API (which one day we will deprecate if my dreams become reality).
-----------------------------------
But then, @philnik reminded me that libc++ was originally built to implement the C++11 standard even on top of a C++03 compiler, and that is actually one of the things [we tell users](https://libcxx.llvm.org/DesignDocs/ExtendedCXX03Support.html). In other words, we never really faithfully implement C++03 anyways. For example, we provide all kinds of things like `std::shared_ptr` in C++03 mode, and those are all C++11 features.
So yeah, I think it's fine to drop this. And it only reinforces my desire to get a discussion started on deprecating C++03 support entirely.
================
Comment at: libcxx/include/__utility/pair.h:486
-#ifndef _LIBCPP_CXX03_LANG
template <class _T1, class _T2>
----------------
This one is definitely good. `std::get(pair)` was added in C++11/14 depending on the overloads, and we probably only did that before rvalue references as a C++03 extension in Clang.
================
Comment at: libcxx/test/std/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp:3
//
-// The LLVM Compiler Infrastructure
-//
----------------
Side comment, but we do seem to have quite a few files that haven't moved to the new license. You could make a NFC with those without review if you want.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133013/new/
https://reviews.llvm.org/D133013
More information about the libcxx-commits
mailing list