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