xref: /llvm-project/libcxx/test/std/input.output/syncstream/syncbuf/helpers.h (revision 17f006207cb233e4988160fe8860cf082bbafe88)
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 #ifndef TEST_STD_INPUT_OUTPUT_SYNCSTREAM_SYNCBUF_SYNCSTREAM_SYNCBUF_MEMBERS_H
10 #define TEST_STD_INPUT_OUTPUT_SYNCSTREAM_SYNCBUF_SYNCSTREAM_SYNCBUF_MEMBERS_H
11 
12 #include <streambuf>
13 #include <syncstream>
14 
15 template <class T>
16 class test_buf : public std::basic_streambuf<T> {
17 public:
18   int id;
19 
id(_id)20   test_buf(int _id = 0) : id(_id) {}
21 
_pptr()22   T* _pptr() { return this->pptr(); }
23 };
24 
25 template <class T, class Alloc = std::allocator<T>>
26 class test_syncbuf : public std::basic_syncbuf<T, std::char_traits<T>, Alloc> {
27 public:
test_syncbuf(test_buf<T> * buf,Alloc alloc)28   test_syncbuf(test_buf<T>* buf, Alloc alloc) : std::basic_syncbuf<T, std::char_traits<T>, Alloc>(buf, alloc) {}
29 
_setp(T * begin,T * end)30   void _setp(T* begin, T* end) { return this->setp(begin, end); }
31 };
32 
33 template <class T>
34 struct test_allocator : std::allocator<T> {
35   int id;
idtest_allocator36   test_allocator(int _id = 0) : id(_id) {}
37 };
38 
39 #endif // TEST_STD_INPUT_OUTPUT_SYNCSTREAM_SYNCBUF_SYNCSTREAM_SYNCBUF_MEMBERS_H
40