2010-05-11 19:42:16 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2010-05-11 21:36:01 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
2010-05-11 19:42:16 +00:00
|
|
|
//
|
2010-11-16 22:09:02 +00:00
|
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
|
|
// Source Licenses. See LICENSE.TXT for details.
|
2010-05-11 19:42:16 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// <string>
|
|
|
|
|
|
|
|
// template<class charT, class traits, class Allocator>
|
|
|
|
// basic_ostream<charT, traits>&
|
|
|
|
// operator<<(basic_ostream<charT, traits>& os,
|
|
|
|
// const basic_string<charT,traits,Allocator>& str);
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
|
|
|
#include <cassert>
|
|
|
|
|
2013-06-28 16:59:19 +00:00
|
|
|
#include "../../min_allocator.h"
|
|
|
|
|
2010-05-11 19:42:16 +00:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::ostringstream out;
|
|
|
|
std::string s("some text");
|
|
|
|
out << s;
|
|
|
|
assert(out.good());
|
|
|
|
assert(s == out.str());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
std::ostringstream out;
|
|
|
|
std::string s("some text");
|
|
|
|
out.width(12);
|
|
|
|
out << s;
|
|
|
|
assert(out.good());
|
|
|
|
assert(" " + s == out.str());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
std::wostringstream out;
|
|
|
|
std::wstring s(L"some text");
|
|
|
|
out << s;
|
|
|
|
assert(out.good());
|
|
|
|
assert(s == out.str());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
std::wostringstream out;
|
|
|
|
std::wstring s(L"some text");
|
|
|
|
out.width(12);
|
|
|
|
out << s;
|
|
|
|
assert(out.good());
|
|
|
|
assert(L" " + s == out.str());
|
|
|
|
}
|
2013-06-28 16:59:19 +00:00
|
|
|
#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
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|