1 // Copyright 2019 Hans Dembinski
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_HISTOGRAM_DETAIL_COUNTING_STREAMBUF_HPP
8 #define BOOST_HISTOGRAM_DETAIL_COUNTING_STREAMBUF_HPP
16 // detect how many characters will be printed by formatted output
17 template <class CharT, class Traits = std::char_traits<CharT>>
18 struct counting_streambuf : std::basic_streambuf<CharT, Traits> {
19 using base_t = std::basic_streambuf<CharT, Traits>;
20 using typename base_t::char_type;
21 using typename base_t::int_type;
23 std::streamsize count = 0;
25 std::streamsize xsputn(const char_type* /* s */, std::streamsize n) override {
30 int_type overflow(int_type ch) override {
37 } // namespace histogram