1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // template <class charT, class traits>
13 // basic_istream<charT,traits>&
14 // ws(basic_istream<charT,traits>& is);
19 template <class CharT>
21 : public std::basic_streambuf<CharT>
23 typedef std::basic_string<CharT> string_type;
24 typedef std::basic_streambuf<CharT> base;
30 testbuf(const string_type& str)
33 base::setg(const_cast<CharT*>(str_.data()),
34 const_cast<CharT*>(str_.data()),
35 const_cast<CharT*>(str_.data()) + str_.size());
38 CharT* eback() const {return base::eback();}
39 CharT* gptr() const {return base::gptr();}
40 CharT* egptr() const {return base::egptr();}
46 testbuf<char> sb(" 123");
50 assert(is.peek() == '1');
53 testbuf<wchar_t> sb(L" 123");
54 std::wistream is(&sb);
57 assert(is.peek() == L'1');
60 testbuf<char> sb(" ");
70 testbuf<wchar_t> sb(L" ");
71 std::wistream is(&sb);