[libcxx-commits] [PATCH] D109066: [libc++] Implement P1951, default arguments for pair's forwarding constructor

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Sep 3 11:52:29 PDT 2021


ldionne added inline comments.


================
Comment at: libcxx/test/std/utilities/utility/pairs/pairs.pair/U_V.pass.cpp:126
+    }
+#endif
+
----------------
Quuxplusone wrote:
> I'd like to see some tests for:
> - SFINAE-friendliness. `template<class T> void foo() -> decltype(std::pair<T, T>({}, {}))` I guess should be SFINAE-friendly.
> - CTAD, even though AIUI the class template arguments will never be deducible. Still, I guess `void foo(auto t) -> decltype(std::pair({}, t))` should be SFINAE-friendly.
> - Both brace-init and parens-init: `std::pair<T, U>({}, {})` and `std::pair<T, U>{{}, {}}`.
> - SFINAE-friendliness of something like this, i.e. we didn't mess up the conditional-explicit-ness of the constructors involved. (I may not have thought this one out sufficiently. pair's constructor overload set is //very// confusing.)
> ```
> struct ExplicitBraceT { explicit ExplicitBraceT(); };
> void f(std::pair<ExplicitBraceT, ExplicitBraceT>);  // #1
> void f(std::pair<BraceInit, BraceInit>);  // #2
> int main() { f({{}, {}}); }  // unambiguously calls #2, right?
> ```
> 
> 
> Btw, there's precedent for this kind of "in standards greater than X, //or// `_LIBCPP_VERSION`" test, here: `libcxx/test/std/utilities/utility/forward/{move,forward}.pass.cpp`
> SFINAE-friendliness. 

Done.

> CTAD, even though AIUI the class template arguments will never be deducible.

Done.

> Both brace-init and parens-init: `std::pair<T, U>({}, {})` and `std::pair<T, U>{{}, {}}`.

Added.

> SFINAE-friendliness of something like this

Done.

> Btw, there's precedent for this kind of "in standards greater than X [...]

I much prefer the way I've done it here - unless I misunderstand something, in `libcxx/test/std/utilities/utility/forward/forward.pass.cpp`, they duplicate the testing code just to account for the special case `C++ == 11 && libc++`.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109066



More information about the libcxx-commits mailing list