mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [
git repo
]
trueFalseT.hpp
Go to the documentation of this file.
1
/** \file trueFalseT.hpp
2
* \brief Declares and defines a true-false virtual type used for boolean template overrides
3
* \ingroup utils_files
4
* \author Jared R. Males (jaredmales@gmail.com)
5
*
6
*/
7
8
//***********************************************************************//
9
// Copyright 2015, 2016, 2017, 2018 Jared R. Males (jaredmales@gmail.com)
10
//
11
// This file is part of mxlib.
12
//
13
// mxlib is free software: you can redistribute it and/or modify
14
// it under the terms of the GNU General Public License as published by
15
// the Free Software Foundation, either version 3 of the License, or
16
// (at your option) any later version.
17
//
18
// mxlib is distributed in the hope that it will be useful,
19
// but WITHOUT ANY WARRANTY; without even the implied warranty of
20
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
// GNU General Public License for more details.
22
//
23
// You should have received a copy of the GNU General Public License
24
// along with mxlib. If not, see <http://www.gnu.org/licenses/>.
25
//***********************************************************************//
26
27
#ifndef trueFalseT_hpp
28
#define trueFalseT_hpp
29
30
namespace
mx
31
{
32
33
namespace
meta
34
{
35
36
///Template declaration of a trueFalseT type.
37
/** The specialized types can be used for tag dispatching, that is achieving SFINAE-like behavior but with function overloading when
38
* identical function signatures are desired. This works because trueFalseT<true> and trueFalseT<false> are
39
* dfferent types.
40
*
41
* This is a slightly simpler construct than std::true_type and std::false_type, which are derived from std::integral_constant.
42
*
43
* This template type is not defined, only the specializations are. The specializations have a typedef of True or False, accordingly,
44
* and a static const member value which evaluates to true or false accordingly.
45
*
46
* \tparam trueFalse bool to choose which of the specializations to invoke.
47
*
48
* \ingroup meta
49
*/
50
template
<
bool
trueFalse>
51
struct
trueFalseT
;
52
53
///The true specialization of trueFalseT.
54
/** \ingroup meta
55
*/
56
template
<>
57
struct
trueFalseT
<true>
58
{
59
typedef
bool
True
;
///< Typedef which can be used for SFINAE
60
static
const
bool
value =
true
;
///< bool member value = true
61
};
62
63
///The false specialization of trueFalseT.
64
/** \ingroup meta
65
*/
66
template
<>
67
struct
trueFalseT
<false>
68
{
69
typedef
bool
False
;
///< Typedef which can be used for SFINAE
70
static
const
bool
value =
false
;
///< bool member value = false
71
};
72
73
}
//namespace meta
74
}
//namespace mx
75
76
77
#endif
//trueFalseT_hpp
mx
The mxlib c++ namespace.
Definition:
mxError.hpp:107
mx::meta::trueFalseT< false >::False
bool False
Typedef which can be used for SFINAE.
Definition:
trueFalseT.hpp:69
mx::meta::trueFalseT< true >::True
bool True
Typedef which can be used for SFINAE.
Definition:
trueFalseT.hpp:59
mx::meta::trueFalseT
Template declaration of a trueFalseT type.
Definition:
trueFalseT.hpp:51
meta
trueFalseT.hpp
Generated on Sun Nov 26 2023 10:58:11 for mxlib by
1.9.1