1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <streambuf> 10 11 // template <class charT, class traits = char_traits<charT> > 12 // class basic_streambuf; 13 14 // void gbump(int n); 15 16 #include <streambuf> 17 #include <cassert> 18 19 template <class CharT> 20 struct test 21 : public std::basic_streambuf<CharT> 22 { 23 typedef std::basic_streambuf<CharT> base; 24 25 test() {} 26 27 void setg(CharT* gbeg, CharT* gnext, CharT* gend) 28 { 29 base::setg(gbeg, gnext, gend); 30 } 31 32 void gbump(int n) 33 { 34 CharT* gbeg = base::eback(); 35 CharT* gnext = base::gptr(); 36 CharT* gend = base::egptr(); 37 base::gbump(n); 38 assert(base::eback() == gbeg); 39 assert(base::gptr() == gnext+n); 40 assert(base::egptr() == gend); 41 } 42 }; 43 44 int main(int, char**) 45 { 46 { 47 test<char> t; 48 char in[] = "ABCDE"; 49 t.setg(in, in+1, in+sizeof(in)/sizeof(in[0])); 50 t.gbump(2); 51 } 52 { 53 test<wchar_t> t; 54 wchar_t in[] = L"ABCDE"; 55 t.setg(in, in+1, in+sizeof(in)/sizeof(in[0])); 56 t.gbump(3); 57 } 58 59 return 0; 60 } 61