knowL: Knowledge Libraries
Loading...
Searching...
No Matches
knowl
src
knowCore
NamedType.h
1
#pragma once
2
3
#include <type_traits>
4
5
namespace
knowCore
6
{
7
struct
NamedTypeOptions
8
{
9
enum
{
10
None = 0,
21
ExplicitConversion
= 1,
22
Default = None,
23
};
24
};
38
template
<
typename
_T_,
typename
_Tag_,
int
_Options_ = NamedTypeOptions::Default>
39
class
NamedType
40
{
41
public
:
42
explicit
NamedType
(
const
_T_& _value) : m_value(_value) {}
43
template
<
int
_Options_2_ = _Options_,
typename
= std::enable_if_t<(_Options_2_ & NamedTypeOptions::ExplicitConversion) == 0>>
44
operator
_T_()
const
45
{
46
return
m_value;
47
}
48
_T_ value()
const
{
49
return
m_value;
50
}
51
private
:
52
_T_ m_value;
53
};
54
}
55
56
#include "Formatter.h"
57
58
template
<
typename
_T_,
typename
_Tag_,
int
_Options_>
59
struct
fmt::formatter<knowCore::NamedType<_T_, _Tag_, _Options_>> :
public
fmt::formatter<_T_> {
60
using
super = fmt::formatter<_T_>;
61
template
<
typename
FormatContext>
62
auto
format(
const
knowCore::NamedType<_T_, _Tag_, _Options_>
& p, FormatContext& ctx) ->
decltype
(ctx.out())
63
{
64
return
super::format(p, ctx);
65
}
66
};
67
68
namespace
std
69
{
70
// NamedTypes are trivial is their base type is trivial
71
template
<
typename
_T_,
typename
_Tag_,
int
_Options_>
72
struct
is_trivial<knowCore::NamedType<_T_, _Tag_, _Options_>>
73
:
public
std::is_trivial<_T_>
74
{
75
};
76
}
knowCore::NamedType
Definition
NamedType.h:40
knowCore::NamedTypeOptions
Definition
NamedType.h:8
knowCore::NamedTypeOptions::ExplicitConversion
@ ExplicitConversion
Definition
NamedType.h:21
Generated by
1.12.0