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
3#ifndef TETL_FORMAT_FMT_BUFFER_HPP
4#define TETL_FORMAT_FMT_BUFFER_HPP
5
9
10namespace etl::detail {
11
12template <typename CharType>
13struct fmt_buffer {
14 using value_type = CharType;
15
16 template <typename It>
17 fmt_buffer(It out) noexcept
18 : _it{addressof(out)}
19 , _pushBack{[](void* ptr, CharType ch) { (*static_cast<It*>(ptr)) = ch; }}
20 {
21 }
22
23 auto push_back(CharType ch) -> void { (_pushBack)(_it, ch); }
24
25private:
26 using push_back_func_t = void (*)(void*, CharType);
27
28 void* _it;
29 push_back_func_t _pushBack;
30};
31
32} // namespace etl::detail
33
34#endif // TETL_FORMAT_FMT_BUFFER_HPP
constexpr auto addressof(T &arg) noexcept -> T *
Obtains the actual address of the object or function arg, even in presence of overloaded operator&.
Definition addressof.hpp:15