capydi
Loading...
Searching...
No Matches
RuntimeRef.hpp
Go to the documentation of this file.
1
#ifndef RUNTIME_REF_HPP_
2
#define RUNTIME_REF_HPP_
3
4
#include "
Reference.hpp
"
5
6
#include <type_traits>
7
8
namespace
capy::meta
9
{
10
11
template
<
typename
T>
12
class
RuntimeRef
13
{
14
public
:
15
using
ReferentType
= T;
16
using
ReferenceType
= T&;
17
using
ConstReferenceType
=
const
T&;
18
19
private
:
20
static
constexpr
bool
IS_CONST = std::is_const_v<ReferentType>;
21
22
public
:
23
constexpr
/* implicit */
RuntimeRef
(
ReferenceType
ref)
24
: ref_ { ref }
25
{}
26
27
public
:
28
constexpr
29
operator
ReferenceType
() const noexcept requires (!IS_CONST)
30
{
31
return
ref_;
32
}
33
34
constexpr
35
operator
ConstReferenceType
() const noexcept
36
{
37
return
ref_;
38
}
39
40
constexpr
41
operator
RuntimeRef<const T>
() const noexcept
42
{
43
return
RuntimeRef<const T>
{ ref_ };
44
}
45
46
private
:
47
ReferenceType
ref_;
48
};
49
50
}
51
52
#endif
// !RUNTIME_REF_HPP_
Reference.hpp
capy::meta::RuntimeRef::RuntimeRef
constexpr RuntimeRef(ReferenceType ref)
Definition
RuntimeRef.hpp:23
capy::meta::RuntimeRef::ReferentType
T ReferentType
Definition
RuntimeRef.hpp:15
capy::meta::RuntimeRef::ConstReferenceType
const T & ConstReferenceType
Definition
RuntimeRef.hpp:17
capy::meta::RuntimeRef::ReferenceType
T & ReferenceType
Definition
RuntimeRef.hpp:16
capy::meta
Definition
Rebind.hpp:7
core
capymeta
include
capymeta
primitives
referencing
RuntimeRef.hpp
Generated by
1.15.0