[libcxx-commits] [PATCH] D114311: [libcxx] Make sequential containers slightly more SFINAE-friendly during CTAD.

Konstantin Varlamov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Nov 19 20:11:11 PST 2021


var-const created this revision.
var-const requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Disable the constructors taking `(size_type, const value_type&,
allocator_type)` if `allocator_type` is not a valid allocator.
Otherwise, these constructors are considered when resolving e.g.
`(int*, int*, NotAnAllocator())`, leading to a hard error during
instantiation. A hard error makes the Standard's requirement to not
consider deduction guides of the form `(Iterator, Iterator,
BadAllocator)` during overload resolution essentially non-functional.

The previous approach was to SFINAE away `allocator_traits`. This patch
SFINAEs away the specific constructors instead, for consistency with
`basic_string` -- see [LWG3076](wg21.link/lwg3076) which describes
a very similar problem for strings (note, however, that unlike LWG3076,
no valid constructor call is affected by the bad instantiation).

Additionally:

- fix SFINAE in `basic_string` to make sure the template parameter is deduced;
- inline the modified constructors.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114311

Files:
  libcxx/include/__memory/allocator_traits.h
  libcxx/include/deque
  libcxx/include/forward_list
  libcxx/include/list
  libcxx/include/string
  libcxx/include/vector

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114311.388683.patch
Type: text/x-patch
Size: 20087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211120/dcf53322/attachment-0001.bin>


More information about the libcxx-commits mailing list