sandbox
Loading...
Searching...
No Matches
small_string.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_UTILITY_SMALL_STRING_HPP_
3#define LIBSBX_UTILITY_SMALL_STRING_HPP_
4
5#include <array>
6#include <functional>
7#include <iterator>
8#include <ostream>
9#include <string_view>
10#include <type_traits>
11#include <cstring>
12
14
15namespace sbx::utility {
16
17template<character Char, typename Traits = std::char_traits<Char>>
19
20 using traits_type = Traits;
21
22public:
23
24 using char_type = Char;
25 using size_type = std::size_t;
26
27 constexpr small_string() {
28 std::memset(_buffer.stack, 0, sizeof(buffer));
29 }
30
31private:
32
33 union buffer {
34 struct heap {
35 char_type* data;
36 size_type size;
37 } heap;
38 char_type stack[sizeof(heap)];
39 } _buffer;
40
41}; // class small_string
42
43} // namespace sbx::utility
44
45#endif // LIBSBX_UTILITY_SMALL_STRING_HPP_
Definition: small_string.hpp:18
Definition: small_string.hpp:34