qxLib
include
qx
ref.h
Go to the documentation of this file.
1
/**
2
3
@file ref.h
4
@author Khrapov
5
@date 23.09.2023
6
@copyright © Nick Khrapov, 2023. All right reserved.
7
8
**/
9
#pragma once
10
11
namespace
qx
12
{
13
14
/**
15
@brief Get a reference to default construct a reference
16
@details This function is useful when you cannot initialise a reference when creating an object,
17
but once it is initialised you can guarantee the validity of the reference
18
@tparam T - reference type
19
@retval - stub reference. do not try to use it as it is invalid
20
**/
21
template
<
class
T>
22
inline
T&
ref
()
23
{
24
static
char
temp;
25
return
reinterpret_cast<
T&
>
(temp);
26
}
27
28
}
// namespace qx
qx::ref
T & ref()
Get a reference to default construct a reference.
Definition:
ref.h:22
Generated by
1.9.1