Scorum
libraries
protocol
include
scorum
protocol
ref.hpp
Go to the documentation of this file.
1
#pragma once
2
#include <memory>
3
4
namespace
scorum
{
5
namespace
utils {
6
7
/*
8
* std::reference_wrapper has special semantics in template argument deduction rules so it doesn't work properly with
9
* fc::static_variant.
10
*
11
* Using custom 'utils::ref' type instead which doesn't have such semantics
12
*/
13
template
<
typename
T>
class
ref
14
{
15
public
:
16
// We need default ctor because of the fc::static_variant's visitor
17
ref
() =
default
;
18
ref
(T& inst)
19
: _inst(std::addressof(inst))
20
{
21
}
22
ref
(
const
ref
&) =
default
;
23
ref
(
ref
&&) =
default
;
24
ref
&
operator=
(
const
ref
&) =
default
;
25
ref
&
operator=
(
ref
&&) =
default
;
26
27
operator
T&()
const
28
{
29
return
*_inst;
30
}
31
32
T&
get
()
const
33
{
34
return
*_inst;
35
}
36
37
private
:
38
T* _inst;
39
};
40
41
template
<
typename
U>
ref<U>
make_ref
(U& r)
42
{
43
return
ref<U>
(r);
44
}
45
}
46
}
scorum::utils::ref
Definition:
ref.hpp:14
scorum::utils::ref::ref
ref()=default
scorum::utils::ref::ref
ref(ref &&)=default
scorum::utils::ref::get
T & get() const
Definition:
ref.hpp:32
scorum::utils::ref::ref
ref(const ref &)=default
scorum::utils::ref::operator=
ref & operator=(ref &&)=default
scorum::utils::ref::operator=
ref & operator=(const ref &)=default
scorum::utils::ref::ref
ref(T &inst)
Definition:
ref.hpp:18
scorum::utils::make_ref
ref< U > make_ref(U &r)
Definition:
ref.hpp:41
scorum
Definition:
asset.cpp:15
Generated on Thu Jun 9 2022 13:04:26 for Scorum by
1.9.1