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 = char_traits<charT> >
13 // class basic_istream;
15 // operator>>(void*& val);
20 template <class CharT>
22 : public std::basic_streambuf<CharT>
24 typedef std::basic_string<CharT> string_type;
25 typedef std::basic_streambuf<CharT> base;
31 testbuf(const string_type& str)
34 base::setg(const_cast<CharT*>(str_.data()),
35 const_cast<CharT*>(str_.data()),
36 const_cast<CharT*>(str_.data()) + str_.size());
39 CharT* eback() const {return base::eback();}
40 CharT* gptr() const {return base::gptr();}
41 CharT* egptr() const {return base::egptr();}
47 std::istream is((std::streambuf*)0);
53 testbuf<char> sb("0");
62 testbuf<char> sb(" 1 ");
66 assert(n == (void*)1);
71 testbuf<wchar_t> sb(L" 1 ");
72 std::wistream is(&sb);
75 assert(n == (void*)1);
80 testbuf<char> sb("12345678");
84 assert(n == (void*)0x12345678);
89 testbuf<wchar_t> sb(L"12345678");
90 std::wistream is(&sb);
93 assert(n == (void*)0x12345678);