Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:44

0001 // Copyright (C) 2016 Andrzej Krzemienski.
0002 //
0003 // Use, modification, and distribution is subject to the Boost Software
0004 // License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt)
0005 //
0006 // copied from https://github.com/akrzemi1/explicit/tree/master/include/ak_toolkit
0007 // last commit: bd572fe05a700cc6766b3d09f8916c9975ccbb45
0008 
0009 #ifndef GAUDIKERNEL_TAGGEDBOOL_H
0010 #define GAUDIKERNEL_TAGGEDBOOL_H
0011 
0012 namespace Gaudi {
0013   namespace tagged_bool_ns { // artificial namespace to prevent ADL lookups in namespace Gaudi
0014 
0015     template <typename Tag>
0016     class tagged_bool {
0017       bool value;
0018       template <typename /*OtherTag*/>
0019       friend class tagged_bool;
0020 
0021     public:
0022       constexpr explicit tagged_bool( bool v ) : value{ v } {}
0023 
0024       constexpr explicit tagged_bool( int )    = delete;
0025       constexpr explicit tagged_bool( double ) = delete;
0026       constexpr explicit tagged_bool( void* )  = delete;
0027 
0028       template <typename OtherTag>
0029       constexpr explicit tagged_bool( tagged_bool<OtherTag> b ) : value{ b.value } {}
0030 
0031       constexpr explicit operator bool() const { return value; }
0032       constexpr tagged_bool operator!() const { return tagged_bool{ !value }; }
0033 
0034       friend constexpr bool operator==( tagged_bool l, tagged_bool r ) { return l.value == r.value; }
0035       friend constexpr bool operator!=( tagged_bool l, tagged_bool r ) { return l.value != r.value; }
0036     };
0037   } // namespace tagged_bool_ns
0038 
0039   using tagged_bool_ns::tagged_bool; // with this tagged_bool is in namespace xplicit but with disabled ADL
0040 } // namespace Gaudi
0041 
0042 #endif