1bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//===----------------------------------------------------------------------===//
2bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//
3f5256e16dfc425c1d466f6308d4026d529ce9e0bHoward Hinnant//                     The LLVM Compiler Infrastructure
4bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//
5b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// This file is dual licensed under the MIT and the University of Illinois Open
6b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// Source Licenses. See LICENSE.TXT for details.
7bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//
8bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//===----------------------------------------------------------------------===//
9bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
10bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// <sstream>
11bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
12bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
13bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// class basic_istringstream
14bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
15bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// void str(const basic_string<charT,traits,Allocator>& s);
16bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
17bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <sstream>
18bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <cassert>
19bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
20bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantint main()
21bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{
22bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    {
23bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        std::istringstream ss(" 123 456");
24bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(ss.rdbuf() != 0);
25bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(ss.good());
26bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(ss.str() == " 123 456");
27bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        int i = 0;
28bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        ss >> i;
29bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(i == 123);
30bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        ss >> i;
31bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(i == 456);
32bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        ss.str(" 789");
33bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        ss.clear();
34bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(ss.good());
35bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(ss.str() == " 789");
36bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        ss >> i;
37bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(i == 789);
38bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    }
39bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    {
40bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        std::wistringstream ss(L" 123 456");
41bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(ss.rdbuf() != 0);
42bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(ss.good());
43bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(ss.str() == L" 123 456");
44bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        int i = 0;
45bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        ss >> i;
46bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(i == 123);
47bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        ss >> i;
48bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(i == 456);
49bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        ss.str(L" 789");
50bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        ss.clear();
51bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(ss.good());
52bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(ss.str() == L" 789");
53bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        ss >> i;
54bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(i == 789);
55bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    }
56bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant}
57