Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
TypeQualifiers.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <ext/set>
9#include <ext/type_traits>
10
11namespace abstraction {
12
14public:
15 enum class TypeQualifierSet {
16 NONE = 0x0,
17 CONST = 0x1,
18 LREF = 0x2,
19 RREF = 0x4,
20 };
21
22private:
23 static constexpr bool is ( TypeQualifierSet first, TypeQualifierSet second ) {
24 return ( static_cast < unsigned > ( first ) & static_cast < unsigned > ( second ) ) == static_cast < unsigned > ( second );
25 }
26
27public:
29 unsigned res = static_cast < unsigned > ( first ) | static_cast < unsigned > ( second );
31 res &= ~ static_cast < unsigned > ( TypeQualifiers::TypeQualifierSet::RREF ); // decay LREF and RREF to LREF
32 return static_cast < TypeQualifierSet > ( res );
33 }
34
35 static constexpr bool isConst ( TypeQualifierSet arg ) {
37 }
38
39 static constexpr bool isRef ( TypeQualifierSet arg ) {
40 return isRvalueRef ( arg ) || isLvalueRef ( arg );
41 }
42
43 static constexpr bool isRvalueRef ( TypeQualifierSet arg ) {
45 }
46
47 static constexpr bool isLvalueRef ( TypeQualifierSet arg ) {
49 }
50
51 template < class Type >
52 static constexpr TypeQualifierSet typeQualifiers ( ) {
54
55 if ( std::is_lvalue_reference < Type >::value )
57
58 if ( std::is_rvalue_reference < Type >::value )
60
61 if ( std::is_const < typename std::remove_reference < Type >::type >::value )
63
64 return res;
65 }
66
67 friend std::ostream & operator << ( std::ostream & os, TypeQualifierSet typeQualifiers );
68};
69
70} /* namespace abstraction */
71
Definition: TypeQualifiers.hpp:13
static constexpr bool isRvalueRef(TypeQualifierSet arg)
Definition: TypeQualifiers.hpp:43
TypeQualifierSet
Definition: TypeQualifiers.hpp:15
static constexpr bool isConst(TypeQualifierSet arg)
Definition: TypeQualifiers.hpp:35
static constexpr bool isRef(TypeQualifierSet arg)
Definition: TypeQualifiers.hpp:39
static constexpr bool isLvalueRef(TypeQualifierSet arg)
Definition: TypeQualifiers.hpp:47
constexpr friend TypeQualifierSet operator|(TypeQualifierSet first, TypeQualifierSet second)
Definition: TypeQualifiers.hpp:28
static constexpr TypeQualifierSet typeQualifiers()
Definition: TypeQualifiers.hpp:52
friend std::ostream & operator<<(std::ostream &os, TypeQualifierSet typeQualifiers)
Definition: TypeQualifiers.cpp:10
Definition: AlgorithmAbstraction.hpp:11
p second
Definition: ToRegExpAlgebraic.h:126
return res
Definition: MinimizeByPartitioning.h:145