From e96f8b52d92ee7d1d13a7a0e1f22a15c2bc52f5b Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Wed, 9 Mar 2016 17:51:43 +0000 Subject: Implement LWG#2583: There is no way to supply an allocator for basic_string(str, pos) llvm-svn: 263036 --- .../basic.string/string.cons/substr.pass.cpp | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'libcxx/test/std/strings/basic.string') diff --git a/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp index 2e42be13a84..3eaf009dfe3 100644 --- a/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp @@ -11,14 +11,21 @@ // // basic_string(const basic_string& str, -// size_type pos, size_type n = npos, +// size_type pos, size_type n, +// const Allocator& a = Allocator()); +// +// basic_string(const basic_string& str, +// size_type pos, // const Allocator& a = Allocator()); #include #include #include +#include +#include #include +#include "test_macros.h" #include "test_allocator.h" #include "min_allocator.h" @@ -91,6 +98,20 @@ test(S str, unsigned pos, unsigned n, const typename S::allocator_type& a) } } +#if TEST_STD_VER >= 11 +void test2583() +{ // LWG #2583 + typedef std::basic_string, test_allocator > StringA; + std::vector>> vs; + StringA s{"1234"}; + vs.emplace_back(s, 2); + + try { vs.emplace_back(s, 5); } + catch (const std::out_of_range&) { return; } + assert(false); +} +#endif + int main() { { @@ -131,7 +152,7 @@ int main() test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 10, A(8)); test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 100, A(8)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef min_allocator A; typedef std::basic_string, A> S; @@ -170,5 +191,7 @@ int main() test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 10, A()); test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 100, A()); } + + test2583(); #endif } -- cgit v1.2.3