[libcxx-commits] [PATCH] D58587: Implement P0433: deduction guides for <map>

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 3 14:11:37 PDT 2019


Quuxplusone marked 8 inline comments as done.
Quuxplusone added inline comments.


================
Comment at: test/std/containers/associative/multimap/multimap.cons/deduct.fail.cpp:60
+    {
+        // refuse to rebind the allocator if Allocator::value_type is not exactly what we expect
+        // std::pair<int, int> arr[] = { {1,1}, {2,2}, {3,3} };
----------------
mclow.lists wrote:
> What's going on here?
> Does this test need to be uncommented? or removed?
The reason it's commented out is that the error message that's actually printed is a hard error from inside `include/map` and I don't know how to write an expected-error line for that. Is that possible? Here's the error as printed:
```
File $ROOT/llvm/projects/libcxx/include/map Line 1671: static_assert failed due to requirement 'is_same<std::__1::pair<int, long>, std::__1::pair<const int, long> >::value' "Allocator::value_type must be same type as value_type"
```


================
Comment at: test/std/containers/associative/multimap/multimap.cons/deduct.pass.cpp:91
+    {
+    std::multimap m{ std::pair{1,1L}, std::pair{2,2L}, std::pair{1,1L}, std::pair{INT_MAX,1L}, std::pair{3,1L} };
+
----------------
Quuxplusone wrote:
> mclow.lists wrote:
> > typedef `using P = std::pair<int, long>;` would make this clearer.
> > Along with ` std::multimap m{ P{1,1L}, P{2,2L}, P{1,1L}, P{INT_MAX,1L}, P{3,1L} };`
> Hmm. I seem to recall that I specifically didn't want to nail down what kind of `pair` was being CTAD'ed — the idea was to keep this specific code (a CTAD `multimap` of `pair{x,y}`s) working even if the CTAD guides on either `multimap` or `pair` are changed in the future. Other tests would handle "a CTAD `multimap` of `pair<A,B>(x,y)`s" and "a CTAD `multimap` of `{x,y}`s."
> Except that I don't see those tests here! So I guess using the concrete type `pair<A,B>` (or just `P`) would be okay.
> 
> I am unsure whether `multimap{ pair{a,b}, pair{c,d} }` can ever produce a different type from `multimap{ pair<A,B>{a,b}, pair<A,B>{c,d} }`. I am pretty sure that those can produce a different type from `multimap{ {a,b}, {c,d} }`.
I found the "CTAD `multimap` of `{x,y}`s" in deduct.fail.cpp. :) 


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D58587





More information about the libcxx-commits mailing list