tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
fmt_buffer.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2023 Tobias Hienzsch
3
4#ifndef TETL_FORMAT_FMT_BUFFER_HPP
5#define TETL_FORMAT_FMT_BUFFER_HPP
6
7#include <etl/_format/format_arg_store.hpp>
8#include <etl/_memory/addressof.hpp>
9#include <etl/_utility/forward.hpp>
10
11namespace etl::detail {
12
13template <typename CharType>
14struct fmt_buffer {
15 using value_type = CharType;
16
17 template <typename It>
18 fmt_buffer(It out) noexcept
19 : _it{addressof(out)}
20 , _pushBack{[](void* ptr, CharType ch) { (*static_cast<It*>(ptr)) = ch; }}
21 {
22 }
23
24 auto push_back(CharType ch) -> void
25 {
26 (_pushBack)(_it, ch);
27 }
28
29private:
30 using push_back_func_t = void (*)(void*, CharType);
31
32 void* _it;
33 push_back_func_t _pushBack;
34};
35
36} // namespace etl::detail
37
38#endif // TETL_FORMAT_FMT_BUFFER_HPP
Definition adjacent_find.hpp:9