mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 18:38:30 +08:00
Implement proposed resolution for LWG#2758. Reviewed as D24446. Normally, I would wait for these to be voted upon at a committee meeting (November), but the current draft standard is broken, and this should fix it. (And if it doesn't, we want to know about it soonest)
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@282342 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -10,9 +10,8 @@
|
||||
// XFAIL: libcpp-no-exceptions
|
||||
// <string>
|
||||
|
||||
// basic_string<charT,traits,Allocator>&
|
||||
// append(basic_string_view<charT,traits> sv, size_type pos, size_type n = npos);
|
||||
// the "= npos" was added for C++14
|
||||
// template <class T>
|
||||
// basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17
|
||||
|
||||
#include <string>
|
||||
#include <string>
|
||||
@@ -121,4 +120,61 @@ int main()
|
||||
test_npos(S(), SV("12345"), 5, S(""));
|
||||
test_npos(S(), SV("12345"), 6, S("not happening"));
|
||||
}
|
||||
{
|
||||
typedef std::string S;
|
||||
typedef std::string_view SV;
|
||||
S s;
|
||||
SV sv = "EFGH";
|
||||
char arr[] = "IJKL";
|
||||
|
||||
s.append("CDEF", 0); // calls append(const char *, len)
|
||||
assert(s == "");
|
||||
s.clear();
|
||||
|
||||
s.append("QRST", 0, std::string::npos); // calls append(string("QRST"), pos, npos)
|
||||
assert(s == "QRST");
|
||||
s.clear();
|
||||
|
||||
s.append(sv, 0); // calls append(T, pos, npos)
|
||||
assert(s == sv);
|
||||
s.clear();
|
||||
|
||||
s.append(sv, 0, std::string::npos); // calls append(T, pos, npos)
|
||||
assert(s == sv);
|
||||
s.clear();
|
||||
|
||||
s.append(arr, 0); // calls append(const char *, len)
|
||||
assert(s == "");
|
||||
s.clear();
|
||||
|
||||
s.append(arr, 0, std::string::npos); // calls append(string("IJKL"), pos, npos)
|
||||
assert(s == "IJKL");
|
||||
s.clear();
|
||||
|
||||
s.append(arr, 0); // calls append(const char *, len)
|
||||
assert(s == "");
|
||||
s.clear();
|
||||
|
||||
{
|
||||
S s = "ABCD";
|
||||
SV sv = s;
|
||||
s.append(sv);
|
||||
assert(s == "ABCDABCD");
|
||||
|
||||
sv = s;
|
||||
s.append(sv, 0, std::string::npos);
|
||||
assert(s == "ABCDABCDABCDABCD");
|
||||
}
|
||||
|
||||
{
|
||||
S s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
SV sv = s;
|
||||
s.append(sv);
|
||||
assert(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
|
||||
sv = s;
|
||||
s.append(sv, 0, std::string::npos);
|
||||
assert(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user