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
13
#include <
libsbx/utility/hash.hpp
>
14
15
namespace
sbx::utility {
16
17
template
<
char
acter Char,
typename
Traits = std::
char
_traits<Char>>
18
class
small_string
{
19
20
using
traits_type = Traits;
21
22
public
:
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
31
private
:
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_
sbx::utility::small_string
Definition:
small_string.hpp:18
hash.hpp
sbx::utility::small_string::buffer::heap
Definition:
small_string.hpp:34
libsbx-utility
libsbx
utility
small_string.hpp
Generated by
1.9.5