Implement LWG #2268: Setting a default argument in the declaration of a member function assign of std::basic_string.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202876 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2014-03-04 19:17:19 +00:00
parent be8a99ad0f
commit a93b5e27a8
6 changed files with 189 additions and 15 deletions

View File

@@ -10,7 +10,8 @@
// <string>
// int compare(size_type pos1, size_type n1, const basic_string& str,
// size_type pos2, size_type n2) const;
// size_type pos2, size_type n2=npos) const;
// the "=npos" was added in C++14
#include <string>
#include <stdexcept>
@@ -44,6 +45,23 @@ test(const S& s, typename S::size_type pos1, typename S::size_type n1,
}
}
template <class S>
void
test_npos(const S& s, typename S::size_type pos1, typename S::size_type n1,
const S& str, typename S::size_type pos2, int x)
{
try
{
assert(sign(s.compare(pos1, n1, str, pos2)) == sign(x));
assert(pos1 <= s.size());
assert(pos2 <= str.size());
}
catch (std::out_of_range&)
{
assert(pos1 > s.size() || pos2 > str.size());
}
}
template <class S>
void test0()
{
@@ -5795,6 +5813,16 @@ void test54()
test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
}
template<class S>
void test55()
{
test_npos(S(""), 0, 0, S(""), 0, 0);
test_npos(S(""), 0, 0, S("abcde"), 0, -5);
test_npos(S("abcde"), 0, 0, S("abcdefghij"), 0, -10);
test_npos(S("abcde"), 0, 0, S("abcdefghij"), 1, -9);
test_npos(S("abcde"), 0, 0, S("abcdefghij"), 5, -5);
}
int main()
{
{
@@ -5854,6 +5882,7 @@ int main()
test52<S>();
test53<S>();
test54<S>();
test55<S>();
}
#if __cplusplus >= 201103L
{
@@ -5913,6 +5942,7 @@ int main()
test52<S>();
test53<S>();
test54<S>();
test55<S>();
}
#endif
}