[libc++] Rework compressed pair constructors.
This patch de-duplicates most compressed pair constructors
to use the same code in C++11 and C++03.
Part of doing that is deleting the "__second_tag()" and replacing
it with a "__value_init_tag()" which has the same effect, but
allows for the removal of the special "one-arg" first element
constructor.
This patch is intended to have no semantic change.
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 549545b64aab77d2a1784062451ee1c33f8324d2
diff --git a/include/string b/include/string
index 4e0b211..488c07a 100644
--- a/include/string
+++ b/include/string
@@ -1736,7 +1736,7 @@
#else
_NOEXCEPT
#endif
-: __r_(__second_tag(), __a)
+: __r_(__value_init_tag(), __a)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -1796,7 +1796,7 @@
template <class _CharT, class _Traits, class _Allocator>
template <class>
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__value_init_tag(), __a)
{
_LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");
__init(__s, traits_type::length(__s));
@@ -1819,7 +1819,7 @@
template <class _CharT, class _Traits, class _Allocator>
inline
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__value_init_tag(), __a)
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
__init(__s, __n);
@@ -1830,7 +1830,7 @@
template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str)
- : __r_(__second_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc()))
+ : __r_(__value_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc()))
{
if (!__str.__is_long())
__r_.first().__r = __str.__r_.first().__r;
@@ -1844,7 +1844,7 @@
template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>::basic_string(
const basic_string& __str, const allocator_type& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__value_init_tag(), __a)
{
if (!__str.__is_long())
__r_.first().__r = __str.__r_.first().__r;
@@ -1878,7 +1878,7 @@
template <class _CharT, class _Traits, class _Allocator>
inline
basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__value_init_tag(), __a)
{
if (__str.__is_long() && __a != __str.__alloc()) // copy, not move
__init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
@@ -1933,7 +1933,7 @@
template <class _CharT, class _Traits, class _Allocator>
template <class>
basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__value_init_tag(), __a)
{
__init(__n, __c);
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1945,7 +1945,7 @@
basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str,
size_type __pos, size_type __n,
const _Allocator& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__value_init_tag(), __a)
{
size_type __str_sz = __str.size();
if (__pos > __str_sz)
@@ -1960,7 +1960,7 @@
inline
basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos,
const _Allocator& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__value_init_tag(), __a)
{
size_type __str_sz = __str.size();
if (__pos > __str_sz)
@@ -1975,7 +1975,7 @@
template <class _Tp, class>
basic_string<_CharT, _Traits, _Allocator>::basic_string(
const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__value_init_tag(), __a)
{
__self_view __sv0 = __t;
__self_view __sv = __sv0.substr(__pos, __n);
@@ -1999,7 +1999,7 @@
template <class _CharT, class _Traits, class _Allocator>
template <class _Tp, class>
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__value_init_tag(), __a)
{
__self_view __sv = __t;
__init(__sv.data(), __sv.size());
@@ -2082,7 +2082,7 @@
inline
basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__value_init_tag(), __a)
{
__init(__first, __last);
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -2108,7 +2108,7 @@
basic_string<_CharT, _Traits, _Allocator>::basic_string(
initializer_list<_CharT> __il, const _Allocator& __a)
- : __r_(__second_tag(), __a)
+ : __r_(__value_init_tag(), __a)
{
__init(__il.begin(), __il.end());
#if _LIBCPP_DEBUG_LEVEL >= 2