repr 0.1
Reconstructable string representations and more
Loading...
Searching...
No Matches
literal.h
Go to the documentation of this file.
1#pragma once
2#include <cstddef>
3#include <type_traits>
4
5namespace librepr {
6
7template <typename T>
8struct is_literal {
9 // don't print type names for fundamental types and string literals
10 constexpr static bool value = std::is_fundamental_v<T> || std::is_same_v<T, char const*>;
11};
12
13template <typename T, std::size_t N>
14struct is_literal<T[N]> {
15 // don't print type names for arrays
16 constexpr static bool value = true;
17};
18
19template <typename T>
20requires std::is_enum_v<T>
21struct is_literal<T> {
22 // don't print type names for enums
23 constexpr static bool value = true;
24};
25
26template <typename T>
27inline constexpr bool is_literal_v = is_literal<T>::value;
28}
Definition ctvi/ctvi.h:9
std::string code_for()
Definition repr:39
constexpr bool is_literal_v
Definition literal.h:27
Definition literal.h:8
static constexpr bool value
Definition literal.h:10