[libcxx-commits] [PATCH] D131495: [libc++] implement "pair" section of P2321R2 `zip`

Konstantin Varlamov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 23 15:15:42 PDT 2022


var-const requested changes to this revision.
var-const added a comment.
This revision now requires changes to proceed.

Thanks a lot for working on this! Sorry about the slow review. I'll take a look at the tests soon.



================
Comment at: libcxx/include/__utility/pair.h:211
+    explicit(!_CheckArgs::template __is_implicit<_U1&, _U2&>()) pair(pair<_U1, _U2>& __p)
+        noexcept((is_nothrow_constructible<first_type, _U1&>::value &&
+                  is_nothrow_constructible<second_type, _U2&>::value))
----------------
The `noexcept` doesn't seem to be in the standard -- we're adding it for consistency with existing constructors, right?


================
Comment at: libcxx/include/__utility/pair.h:319
+    const pair& operator=(pair const& __p) const
+      noexcept(is_nothrow_copy_assignable_v<const first_type> &&
+               is_nothrow_copy_assignable_v<const second_type>)
----------------
Same question here re. `noexcept`.


================
Comment at: libcxx/include/__utility/pair.h:384
+    void swap(const pair& __p) const
+        _NOEXCEPT_(__is_nothrow_swappable<const first_type>::value &&
+                   __is_nothrow_swappable<const second_type>::value)
----------------
I think you don't have to use the macro and can use just plain `noexcept` since it won't be available in older language modes.


================
Comment at: libcxx/include/__utility/pair.h:514
+void swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
+    _NOEXCEPT_(__is_nothrow_swappable<const _T1>::value &&
+               __is_nothrow_swappable<const _T2>::value)
----------------
The `noexcept` specification is different from the standard -- looks like it's copied from the member version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131495



More information about the libcxx-commits mailing list