| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 AK_TOOLKIT_EXPLICIT_TAGGED_BOOL_HEADER_GUARD_
10 #define AK_TOOLKIT_EXPLICIT_TAGGED_BOOL_HEADER_GUARD_
11
12 namespace Gaudi
13 {
14 namespace tagged_bool_ns
15 { // artificial namespace to prevent ADL lookups in namespace Gaudi
16
17 template <typename Tag>
18 class tagged_bool
19 {
20 bool value;
21 template <typename /*OtherTag*/>
22 friend class tagged_bool;
23
24 public:
25 constexpr explicit tagged_bool( bool v ) : value{v} {}
26
27 constexpr explicit tagged_bool( int ) = delete;
28 constexpr explicit tagged_bool( double ) = delete;
29 constexpr explicit tagged_bool( void* ) = delete;
30
31 template <typename OtherTag>
32 constexpr explicit tagged_bool( tagged_bool<OtherTag> b ) : value{b.value}
33 {
34 }
35
36 constexpr explicit operator bool() const { return value; }
37 constexpr tagged_bool operator!() const { return tagged_bool{!value}; }
38
39 friend constexpr bool operator==( tagged_bool l, tagged_bool r ) { return l.value == r.value; }
40 friend constexpr bool operator!=( tagged_bool l, tagged_bool r ) { return l.value != r.value; }
41 };
42 }
43
44 using tagged_bool_ns::tagged_bool; // with this tagged_bool is in namespace xplicit but with disabled ADL
45 }
46
47 #endif
Gaudi::tagged_bool_ns::tagged_bool::tagged_bool
constexpr tagged_bool(bool v)
Definition: TaggedBool.h:25
Gaudi::tagged_bool_ns::tagged_bool::operator!
constexpr tagged_bool operator!() const
Definition: TaggedBool.h:37
Gaudi::tagged_bool_ns::tagged_bool::operator==
friend constexpr bool operator==(tagged_bool l, tagged_bool r)
Definition: TaggedBool.h:39
Gaudi::tagged_bool_ns::tagged_bool::tagged_bool
constexpr tagged_bool(tagged_bool< OtherTag > b)
Definition: TaggedBool.h:32
Gaudi::tagged_bool_ns::tagged_bool::tagged_bool
friend class tagged_bool
Definition: TaggedBool.h:22
gaudirun.l
dictionary l
Definition: gaudirun.py:440
Gaudi::tagged_bool_ns::tagged_bool
Definition: TaggedBool.h:18
Gaudi::tagged_bool_ns::tagged_bool::value
bool value
Definition: TaggedBool.h:20
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
Gaudi::tagged_bool_ns::tagged_bool::operator!=
friend constexpr bool operator!=(tagged_bool l, tagged_bool r)
Definition: TaggedBool.h:40