Revert "Revert "Merge to upstream r304942.""

This reverts commit 38a0d5af7e.

Test: make checkbuild
Test: ./run_tests.py
Test: ./run_tests.py --bitness 64
This commit is contained in:
Dan Albert
2018-01-17 14:21:02 -08:00
parent 38a0d5af7e
commit c79549b70e
1102 changed files with 19092 additions and 14798 deletions

View File

@@ -7,13 +7,12 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <string>
// iterator insert(const_iterator p, initializer_list<charT> il);
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
#include <string>
#include <cassert>
@@ -22,14 +21,12 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::string s("123456");
std::string::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
assert(i - s.begin() == 3);
assert(s == "123abc456");
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s("123456");
@@ -37,14 +34,4 @@ int main()
assert(i - s.begin() == 3);
assert(s == "123abc456");
}
#endif
#if _LIBCPP_DEBUG >= 1
{
std::string s;
std::string s2;
s.insert(s2.begin(), {'a', 'b', 'c'});
assert(false);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -188,10 +188,35 @@ int main()
{ // test assigning a different type
typedef std::string S;
const uint8_t p[] = "ABCD";
const uint8_t p[] = "ABCD";
S s;
s.insert(s.begin(), p, p + 4);
assert(s == "ABCD");
S s;
s.insert(s.begin(), p, p + 4);
assert(s == "ABCD");
}
{ // test with a move iterator that returns char&&
typedef input_iterator<const char*> It;
typedef std::move_iterator<It> MoveIt;
const char p[] = "ABCD";
std::string s;
s.insert(s.begin(), MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1)));
assert(s == "ABCD");
}
{ // test with a move iterator that returns char&&
typedef forward_iterator<const char*> It;
typedef std::move_iterator<It> MoveIt;
const char p[] = "ABCD";
std::string s;
s.insert(s.begin(), MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1)));
assert(s == "ABCD");
}
{ // test with a move iterator that returns char&&
typedef const char* It;
typedef std::move_iterator<It> MoveIt;
const char p[] = "ABCD";
std::string s;
s.insert(s.begin(), MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1)));
assert(s == "ABCD");
}
}