1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <streambuf> 11 12// template <class charT, class traits = char_traits<charT> > 13// class basic_streambuf; 14 15// streamsize in_avail(); 16 17#include <streambuf> 18#include <cassert> 19 20int showmanyc_called = 0; 21 22template <class CharT> 23struct test 24 : public std::basic_streambuf<CharT> 25{ 26 typedef std::basic_streambuf<CharT> base; 27 28 test() {} 29 30 void setg(CharT* gbeg, CharT* gnext, CharT* gend) 31 { 32 base::setg(gbeg, gnext, gend); 33 } 34protected: 35 std::streamsize showmanyc() 36 { 37 ++showmanyc_called; 38 return 5; 39 } 40}; 41 42int main() 43{ 44 { 45 test<char> t; 46 assert(t.in_avail() == 5); 47 assert(showmanyc_called == 1); 48 char in[5]; 49 t.setg(in, in+2, in+5); 50 assert(t.in_avail() == 3); 51 } 52} 53