summaryrefslogtreecommitdiffstats
path: root/src/safe/mutableref.h
blob: fb658253a876d036e94d55ef3d01f40f868f921a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
 * @file mutableref.h
 * @author L.-C. C.
 * @brief
 * @version 0.1
 * @date 2020-01-03
 *
 * @copyright Copyright (c) 2020
 *
 */

#pragma once

#include <utility>

namespace safe
{
	namespace impl
	{
		/**
		 * @brief A helper class that defines a member variable of type
		 * Type. The variable is defined "mutable Type" if Type is not a
		 * reference, the variable is "Type&" if Type is a reference.
		 *
		 * @tparam Type The type of the variable to define.
		 */
		template<typename Type>
		struct MutableIfNotReference
		{
			/// Mutable Type object.
			mutable Type get;
		};
		template<typename Type>
		struct MutableIfNotReference<Type&>
		{
			/// Reference to a Type object.
			Type& get;
		};
	} // namespace impl
} // namespace safe