17#ifndef TOOLBOX_UTIL_STREAM_HPP
18#define TOOLBOX_UTIL_STREAM_HPP
25inline namespace util {
37template <std::
size_t MaxN>
105 if (storage_ !=
nullptr) [[
likely]] {
106 return MaxN - bytes_written_;
114 assert(storage_ !=
nullptr);
116 return static_cast<char*
>(
buf_base) + bytes_written_;
120 char* do_prepare_space(std::size_t
num_bytes)
137 void do_set_badbit() { badbit_ =
true; }
140 std::size_t bytes_written_{0
u};
144template <std::
size_t MaxN>
165 explicit operator bool()
const {
return !badbit_; }
177 std::size_t available()
noexcept {
return BufSize - bytes_written_; }
179 char* wptr()
noexcept {
return buf_ + bytes_written_; }
182 char* do_prepare_space(std::size_t
num_bytes)
203 void do_set_badbit() { badbit_ =
true; }
208 static constexpr std::size_t BufSize
212 std::size_t bytes_written_{0
u};
217template <
class StreamT>
250 const char* delim_{
nullptr};
254template <
class StreamT,
class DelimT>
267 DelimT delim)
noexcept(std::is_nothrow_move_constructible_v<DelimT>)
299static_assert(std::output_iterator<OStreamIterator<OStream<4096>>,
const char&>,
"");
300static_assert(std::output_iterator<OStreamJoiner<OStream<4096>,
int>,
const char&>,
"");