diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-04-28 17:46:01 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-04-28 17:56:50 +0100 |
commit | d96db15967e78d7cecea3b1cf3169ceb924678ac (patch) | |
tree | 4d6dd96a448af957090569668408642b8a2ad7c5 /gcc | |
parent | 668df9e769e7d89bcefa07f72b68dcae9a8f3970 (diff) | |
download | gcc-d96db15967e78d7cecea3b1cf3169ceb924678ac.zip gcc-d96db15967e78d7cecea3b1cf3169ceb924678ac.tar.gz gcc-d96db15967e78d7cecea3b1cf3169ceb924678ac.tar.bz2 |
libstdc++: Deprecate non-standard std::pair constructors [PR 99957]
This deprecates the non-standard std::pair constructors that support
construction from an rvalue and a literal zero used as a null pointer
constant. We can't just add the deprecated attribute to those
constructors, because they're currently used by correct code when they
are a better match than the constructors required by the standard e.g.
int i = 0;
const int j = 0;
std::pair<int, int> p(i, j); // uses pair(U1&&, const int&)
This patch adjusts the parameter types and constraints of those
constructors so that they only get used for literal zeros, and the
pair(U1&&, U2&&) constructor gets used otherwise. Once they're only used
for initializations that should be ill-formed we can add the deprecated
attribute.
The deprecated attribute is used to suggest that the user code uses
nullptr, which avoids the problem of 0 deducing as int instead of a null
pointer constant.
libstdc++-v3/ChangeLog:
PR libstdc++/99957
* include/bits/stl_pair.h (_PCC::_MoveCopyPair, _PCC::_CopyMovePair):
Combine and replace with ...
(_PCC::_DeprConsPair): New SFINAE helper function.
(pair): Merge preprocessor blocks so that all C++03 members
are defined together at the end.
(pair::pair(const _T1&, _U2&&), pair::pair(_U1&&, const _T2&)):
Replace _T1 and _T2 parameters with __null_ptr_constant and
adjust constraints.
* testsuite/20_util/pair/40925.cc: Use nullptr instead of 0.
* testsuite/20_util/pair/cons/explicit_construct.cc: Likewise.
* testsuite/20_util/pair/cons/99957.cc: New test.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions