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

Marshall Clow via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 29 10:49:35 PDT 2019


mclow.lists added a comment.

Almost there - and I'm on the hook for comments on the reference stuff.



================
Comment at: test/std/containers/associative/map/map.cons/deduct.pass.cpp:87
+    std::map<int, long> source;
+    std::map m(source, std::allocator<int>());
+    ASSERT_SAME_TYPE(decltype(m), decltype(source));
----------------
Quuxplusone wrote:
> mclow.lists wrote:
> > This works? I would think that it should not. We rebind the allocator internally into something else, but we should probably reject this. [But not in this patch]
> This is me getting a jump start on [P1518 Stop overconstraining allocators in container deduction guides](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1518r0.html#overconst2).
> 
> Since
> 
>     std::map<int, long> m(source, std::allocator<int>());
> 
> works (without CTAD), Mike Spertus (as of February) and I believe that
> 
>     std::map m(source, std::allocator<int>());
> 
> should work //with// CTAD as well.
I don't believe that either should work.

`std::vector<long, std::allocator<int>> m;`
doesn't work, nor does:
```
long l[] = {1L };
std::vector v(std::begin(l), std::end(l), std::allocator<int>());
```

The fact that it works today for `map` and `set` is due to insufficient checking in libc++


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