repr
0.1
Reconstructable string representations and more
Loading...
Searching...
No Matches
util/string/util.h
Go to the documentation of this file.
1
#pragma once
2
#include <
cstddef
>
3
#include <
concepts
>
4
#include <
string
>
5
6
namespace
librepr::detail
{
7
template
<
typename
T>
8
concept
string_like
=
requires
(T& t) {
9
t.size();
10
{ t.data() } -> std::convertible_to<const char*>;
11
};
12
13
template
<std::
size_t
N>
14
constexpr
std::size_t
strsize
(
const
char
(&)[
N
]) {
15
return
(
N
- 1U);
16
}
17
18
constexpr
std::size_t
strsize
(
const
char
* str) {
19
return
std::char_traits<char>::length
(str);
20
}
21
22
template
<
string
_like T>
23
constexpr
std::size_t
strsize
(T&& t) {
24
return
t.size();
25
}
26
}
// namespace librepr::detail
librepr::detail::string_like
Definition
util/string/util.h:8
concepts
cstddef
std::char_traits::length
T length(T... args)
librepr::detail
Definition
assert.h:89
librepr::detail::strsize
constexpr std::size_t strsize(const char(&)[N])
Definition
util/string/util.h:14
librepr::code_for
std::string code_for()
Definition
repr:39
std::size_t
string
include
librepr
util
string
util.h
Generated by
1.9.8, using the excellent
Doxygen Awesome
Theme