repr
0.1
Reconstructable string representations and more
Toggle main menu visibility
Main Page
Installation
Usage
Customization
Extending
FAQ
CI Results
Test
Benchmark
API Documentation
Namespace List
Namespace List
Namespace Members
All
_
a
c
d
e
f
g
i
l
m
n
o
p
r
s
t
u
v
w
Functions
_
a
c
d
e
f
g
i
l
m
n
o
r
s
t
u
v
w
Variables
Typedefs
Enumerations
Concept List
Class List
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Functions
_
a
c
e
f
g
i
l
m
n
o
p
r
s
t
v
w
~
Variables
a
b
c
d
e
f
g
i
k
l
m
n
o
p
q
r
s
t
u
v
Typedefs
a
c
d
e
f
g
h
l
m
p
r
s
t
u
v
w
Enumerations
Enumerator
Related Symbols
File List
File List
File Members
All
_
l
n
o
r
u
Variables
Macros
_
l
o
r
u
Examples
Source Code
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Concepts
Loading...
Searching...
No Matches
const_string.h
Go to the documentation of this file.
#pragma once
#include <
algorithm
>
#include <
cstddef
>
#include <
string_view
>
namespace
librepr
{
template
<std::
size_t
N>
struct
[[
nodiscard
]]
const_string
{
char
value[
N
+ 1]{};
constexpr
static
auto
size =
N
;
constexpr
const_string
() =
default
;
constexpr
explicit
(
false
)
const_string
(
char
const
(&
literal
)[
N
+ 1]) {
// NOLINT
std::copy
(
literal
,
literal
+
N
,
std::begin
(value));
}
constexpr
explicit
(
false
)
const_string
(
char
const
(&
literal
)[
N
+ 1]) {
// NOLINT
{
…
}
constexpr
explicit
const_string
(
std::string_view
data) {
std::copy
(data.data(), data.data() +
N
,
std::begin
(value));
}
constexpr
explicit
const_string
(
std::string_view
data) {
…
}
[[
nodiscard
]]
constexpr
explicit
operator
std::string_view
()
const
noexcept
{
return
std::string_view
{value}; }
[[
nodiscard
]]
constexpr
explicit
operator
char
const
*()
const
noexcept
{
return
value; }
[[
nodiscard
]]
constexpr
auto
to_sv
()
const
noexcept
{
return
std::string_view
{value}; }
[[
nodiscard
]]
constexpr
bool
empty
()
const
noexcept
{
return
size == 0; }
[[
nodiscard
]]
constexpr
char
const
&
operator[]
(
std::size_t
Idx
)
const
{
return
value[
Idx
]; }
friend
constexpr
auto
operator==
(
const_string
lhs
,
std::string_view
rhs
)
noexcept
{
return
rhs
==
lhs
.data; }
};
struct
[[
nodiscard
]]
const_string
{
…
};
template
<std::
size_t
N>
const_string
(
char
const
(&)[
N
]) ->
const_string
<
N
- 1>;
}
// namespace librepr::detail
include
librepr
util
string
const_string.h
Generated by
1.9.8, using the excellent
Doxygen Awesome
Theme