5#ifndef MLAB_TYPE_NAME_HPP
6#define MLAB_TYPE_NAME_HPP
17 template <std::
size_t N>
21 [[nodiscard]] std::size_t
constexpr size()
const;
26 template <std::
size_t M>
29 [[nodiscard]]
constexpr std::size_t
find_last_of(std::initializer_list<char> cs)
const;
31 template <std::
size_t Start, std::
size_t End>
32 [[nodiscard]]
constexpr auto substr()
const;
34 [[nodiscard]]
operator std::string()
const;
37 template <
class T, std::
size_t BufSize = 256>
42 template <std::
size_t N>
47 template <std::
size_t N>
49 std::copy_n(s,
size(), std::begin(
data));
52 template <std::
size_t N>
55 for (; i < N - 1; ++i) {
66 template <std::
size_t N>
67 template <std::
size_t M>
69 return std::distance(std::begin(
data), std::search(std::begin(
data), std::end(
data), std::begin(subs.
data), std::end(subs.
data)));
72 template <std::
size_t N>
74 using iterator_t =
decltype(std::begin(
data));
75 auto rbegin = std::reverse_iterator<iterator_t>(std::end(
data));
76 auto rend = std::reverse_iterator<iterator_t>(std::begin(
data));
77 auto it = std::find_first_of(rbegin, rend, std::begin(cs), std::end(cs));
78 auto pos = std::distance(it, rend);
79 return pos >= 1 ?
pos - 1 : N;
82 template <std::
size_t N>
83 template <std::
size_t Start, std::
size_t End>
85 static_assert(Start < End and End <= N);
87 retval.
data[End - Start] =
'\0';
91 template <std::
size_t N>
93 return std::string{
data, std::find(std::begin(
data), std::end(
data),
'\0')};
96 template <
class T, std::
size_t BufSize>
101 if constexpr (t_pos >= BufSize or bufsize_pos >= BufSize or t_pos + 4 >= bufsize_pos) {
104 constexpr auto candidate = method_name.template substr<t_pos + 4, bufsize_pos>();
105 constexpr std::size_t t_end = candidate.find_last_of({
',',
';'});
106 if constexpr (t_end >= candidate.size()) {
109 return candidate.template substr<0, t_end>();
struct mlab::null_terminated_tag null_terminated
constexpr auto type_name()
Definition type_name.hpp:97
Definition type_name.hpp:18
constexpr std::size_t find(fixed_size_string< M > subs) const
Definition type_name.hpp:68
constexpr std::size_t find_last_of(std::initializer_list< char > cs) const
Definition type_name.hpp:73
std::size_t constexpr size() const
Definition type_name.hpp:43
char data[N]
Definition type_name.hpp:19
constexpr auto substr() const
Definition type_name.hpp:84
constexpr fixed_size_string(const char s[N])
Definition type_name.hpp:48
Definition type_name.hpp:14