Implement full support for non-pointer pointers in custom allocators for string. This completes the custom pointer support for the entire library.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@185167 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@@ -46,4 +48,34 @@ int main()
|
||||
assert(in.eof());
|
||||
assert(s == L" ghij");
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
std::istringstream in(" abc\n def\n ghij");
|
||||
S s("initial text");
|
||||
getline(in, s);
|
||||
assert(in.good());
|
||||
assert(s == " abc");
|
||||
getline(in, s);
|
||||
assert(in.good());
|
||||
assert(s == " def");
|
||||
getline(in, s);
|
||||
assert(in.eof());
|
||||
assert(s == " ghij");
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
|
||||
std::wistringstream in(L" abc\n def\n ghij");
|
||||
S s(L"initial text");
|
||||
getline(in, s);
|
||||
assert(in.good());
|
||||
assert(s == L" abc");
|
||||
getline(in, s);
|
||||
assert(in.good());
|
||||
assert(s == L" def");
|
||||
getline(in, s);
|
||||
assert(in.eof());
|
||||
assert(s == L" ghij");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -18,6 +18,8 @@
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@@ -52,4 +54,40 @@ int main()
|
||||
assert(in.eof());
|
||||
assert(s == L" ghij");
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
std::istringstream in(" abc* def** ghij");
|
||||
S s("initial text");
|
||||
getline(in, s, '*');
|
||||
assert(in.good());
|
||||
assert(s == " abc");
|
||||
getline(in, s, '*');
|
||||
assert(in.good());
|
||||
assert(s == " def");
|
||||
getline(in, s, '*');
|
||||
assert(in.good());
|
||||
assert(s == "");
|
||||
getline(in, s, '*');
|
||||
assert(in.eof());
|
||||
assert(s == " ghij");
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
|
||||
std::wistringstream in(L" abc* def** ghij");
|
||||
S s(L"initial text");
|
||||
getline(in, s, L'*');
|
||||
assert(in.good());
|
||||
assert(s == L" abc");
|
||||
getline(in, s, L'*');
|
||||
assert(in.good());
|
||||
assert(s == L" def");
|
||||
getline(in, s, L'*');
|
||||
assert(in.good());
|
||||
assert(s == L"");
|
||||
getline(in, s, L'*');
|
||||
assert(in.eof());
|
||||
assert(s == L" ghij");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -18,6 +18,8 @@
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
@@ -31,5 +33,19 @@ int main()
|
||||
getline(std::wistringstream(L" abc* def* ghij"), s, L'*');
|
||||
assert(s == L" abc");
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
S s("initial text");
|
||||
getline(std::istringstream(" abc* def* ghij"), s, '*');
|
||||
assert(s == " abc");
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
|
||||
S s(L"initial text");
|
||||
getline(std::wistringstream(L" abc* def* ghij"), s, L'*');
|
||||
assert(s == L" abc");
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
|
@@ -18,6 +18,8 @@
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
@@ -31,5 +33,19 @@ int main()
|
||||
getline(std::wistringstream(L" abc\n def\n ghij"), s);
|
||||
assert(s == L" abc");
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
S s("initial text");
|
||||
getline(std::istringstream(" abc\n def\n ghij"), s);
|
||||
assert(s == " abc");
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
|
||||
S s(L"initial text");
|
||||
getline(std::wistringstream(L" abc\n def\n ghij"), s);
|
||||
assert(s == L" abc");
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
|
@@ -18,6 +18,8 @@
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@@ -64,4 +66,52 @@ int main()
|
||||
in >> s;
|
||||
assert(in.fail());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
std::istringstream in("a bc defghij");
|
||||
S s("initial text");
|
||||
in >> s;
|
||||
assert(in.good());
|
||||
assert(s == "a");
|
||||
assert(in.peek() == ' ');
|
||||
in >> s;
|
||||
assert(in.good());
|
||||
assert(s == "bc");
|
||||
assert(in.peek() == ' ');
|
||||
in.width(3);
|
||||
in >> s;
|
||||
assert(in.good());
|
||||
assert(s == "def");
|
||||
assert(in.peek() == 'g');
|
||||
in >> s;
|
||||
assert(in.eof());
|
||||
assert(s == "ghij");
|
||||
in >> s;
|
||||
assert(in.fail());
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
|
||||
std::wistringstream in(L"a bc defghij");
|
||||
S s(L"initial text");
|
||||
in >> s;
|
||||
assert(in.good());
|
||||
assert(s == L"a");
|
||||
assert(in.peek() == L' ');
|
||||
in >> s;
|
||||
assert(in.good());
|
||||
assert(s == L"bc");
|
||||
assert(in.peek() == L' ');
|
||||
in.width(3);
|
||||
in >> s;
|
||||
assert(in.good());
|
||||
assert(s == L"def");
|
||||
assert(in.peek() == L'g');
|
||||
in >> s;
|
||||
assert(in.eof());
|
||||
assert(s == L"ghij");
|
||||
in >> s;
|
||||
assert(in.fail());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -18,6 +18,8 @@
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@@ -50,4 +52,40 @@ int main()
|
||||
assert(out.good());
|
||||
assert(L" " + s == out.str());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
|
||||
S s("some text");
|
||||
out << s;
|
||||
assert(out.good());
|
||||
assert(s == out.str());
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
|
||||
S s("some text");
|
||||
out.width(12);
|
||||
out << s;
|
||||
assert(out.good());
|
||||
assert(" " + s == out.str());
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
|
||||
std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
|
||||
S s(L"some text");
|
||||
out << s;
|
||||
assert(out.good());
|
||||
assert(s == out.str());
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
|
||||
std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
|
||||
S s(L"some text");
|
||||
out.width(12);
|
||||
out << s;
|
||||
assert(out.good());
|
||||
assert(L" " + s == out.str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user