blob: 0aa7e1afcb17eb9d3718efe817a07cab4a2660cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM
// <strstream>
// class strstreambuf
// strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
#include <strstream>
#include <cassert>
#include "test_macros.h"
int called = 0;
void* my_alloc(std::size_t)
{
static char buf[10000];
++called;
return buf;
}
void my_free(void*)
{
++called;
}
struct test
: std::strstreambuf
{
test(void* (*palloc_arg)(std::size_t), void (*pfree_arg)(void*))
: std::strstreambuf(palloc_arg, pfree_arg) {}
virtual int_type overflow(int_type c)
{return std::strstreambuf::overflow(c);}
};
int main(int, char**)
{
{
test s(my_alloc, my_free);
assert(called == 0);
s.overflow('a');
assert(called == 1);
}
assert(called == 2);
return 0;
}
|