| The Gaudi Framework v32r1 (f65d50dc)

TaggedBool.h
Go to the documentation of this file.
1 // Copyright (C) 2016 Andrzej Krzemienski.
2 //
3 // Use, modification, and distribution is subject to the Boost Software
4 // License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt)
5 //
6 // copied from https://github.com/akrzemi1/explicit/tree/master/include/ak_toolkit
7 // last commit: bd572fe05a700cc6766b3d09f8916c9975ccbb45
8
9 #ifndef GAUDIKERNEL_TAGGEDBOOL_H
10 #define GAUDIKERNEL_TAGGEDBOOL_H
11
12 namespace Gaudi {
13 namespace tagged_bool_ns { // artificial namespace to prevent ADL lookups in namespace Gaudi
14
15 template <typename Tag>
16 class tagged_bool {
17 bool value;
18 template <typename /*OtherTag*/>
19 friend class tagged_bool;
20
21 public:
22 constexpr explicit tagged_bool( bool v ) : value{v} {}
23
24 constexpr explicit tagged_bool( int ) = delete;
25 constexpr explicit tagged_bool( double ) = delete;
26 constexpr explicit tagged_bool( void* ) = delete;
27
28 template <typename OtherTag>
29 constexpr explicit tagged_bool( tagged_bool<OtherTag> b ) : value{b.value} {}
30
31 constexpr explicit operator bool() const { return value; }
32 constexpr tagged_bool operator!() const { return tagged_bool{!value}; }
33
34 friend constexpr bool operator==( tagged_bool l, tagged_bool r ) { return l.value == r.value; }
35 friend constexpr bool operator!=( tagged_bool l, tagged_bool r ) { return l.value != r.value; }
36 };
37 } // namespace tagged_bool_ns
38
39 using tagged_bool_ns::tagged_bool; // with this tagged_bool is in namespace xplicit but with disabled ADL
40 } // namespace Gaudi
41
42 #endif
Gaudi::tagged_bool_ns::tagged_bool::tagged_bool
constexpr tagged_bool(bool v)
Definition: TaggedBool.h:22
Gaudi::tagged_bool_ns::tagged_bool::operator==
friend constexpr bool operator==(tagged_bool l, tagged_bool r)
Definition: TaggedBool.h:34
Gaudi::tagged_bool_ns::tagged_bool::tagged_bool
constexpr tagged_bool(tagged_bool< OtherTag > b)
Definition: TaggedBool.h:29
Gaudi::tagged_bool_ns::tagged_bool::tagged_bool
friend class tagged_bool
Definition: TaggedBool.h:19
gaudirun.l
dictionary l
Definition: gaudirun.py:521
Gaudi::tagged_bool_ns::tagged_bool
Definition: TaggedBool.h:16
Gaudi::tagged_bool_ns::tagged_bool::value
bool value
Definition: TaggedBool.h:17
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
Gaudi::tagged_bool_ns::tagged_bool::operator!
constexpr tagged_bool operator!() const
Definition: TaggedBool.h:32
Gaudi::tagged_bool_ns::tagged_bool::operator!=
friend constexpr bool operator!=(tagged_bool l, tagged_bool r)
Definition: TaggedBool.h:35