11
11
#include < type_traits>
12
12
#include < typeinfo>
13
13
#include < string>
14
+ #include < bitset>
14
15
15
16
namespace chaiscript
16
17
{
@@ -32,17 +33,17 @@ namespace chaiscript
32
33
CHAISCRIPT_CONSTEXPR Type_Info (bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void,
33
34
bool t_is_arithmetic, const std::type_info *t_ti, const std::type_info *t_bare_ti)
34
35
: m_type_info(t_ti), m_bare_type_info(t_bare_ti),
35
- m_is_const(t_is_const), m_is_reference(t_is_reference), m_is_pointer(t_is_pointer),
36
- m_is_void(t_is_void), m_is_arithmetic(t_is_arithmetic),
37
- m_is_undef(false )
36
+ m_flags((t_is_const << is_const_flag)
37
+ + (t_is_reference << is_reference_flag)
38
+ + (t_is_pointer << is_pointer_flag)
39
+ + (t_is_void << is_void_flag)
40
+ + (t_is_arithmetic << is_arithmetic_flag))
38
41
{
39
42
}
40
43
41
44
CHAISCRIPT_CONSTEXPR Type_Info ()
42
45
: m_type_info(nullptr ), m_bare_type_info(nullptr ),
43
- m_is_const(false ), m_is_reference(false ), m_is_pointer(false ),
44
- m_is_void(false ), m_is_arithmetic(false ),
45
- m_is_undef(true )
46
+ m_flags(1 << is_undef_flag)
46
47
{
47
48
}
48
49
@@ -83,12 +84,12 @@ namespace chaiscript
83
84
&& (*m_bare_type_info) == ti;
84
85
}
85
86
86
- CHAISCRIPT_CONSTEXPR bool is_const () const CHAISCRIPT_NOEXCEPT { return m_is_const ; }
87
- CHAISCRIPT_CONSTEXPR bool is_reference () const CHAISCRIPT_NOEXCEPT { return m_is_reference ; }
88
- CHAISCRIPT_CONSTEXPR bool is_void () const CHAISCRIPT_NOEXCEPT { return m_is_void ; }
89
- CHAISCRIPT_CONSTEXPR bool is_arithmetic () const CHAISCRIPT_NOEXCEPT { return m_is_arithmetic ; }
90
- CHAISCRIPT_CONSTEXPR bool is_undef () const CHAISCRIPT_NOEXCEPT { return m_is_undef ; }
91
- CHAISCRIPT_CONSTEXPR bool is_pointer () const CHAISCRIPT_NOEXCEPT { return m_is_pointer ; }
87
+ CHAISCRIPT_CONSTEXPR bool is_const () const CHAISCRIPT_NOEXCEPT { return m_flags[is_const_flag] ; }
88
+ CHAISCRIPT_CONSTEXPR bool is_reference () const CHAISCRIPT_NOEXCEPT { return m_flags[is_reference_flag] ; }
89
+ CHAISCRIPT_CONSTEXPR bool is_void () const CHAISCRIPT_NOEXCEPT { return m_flags[is_void_flag] ; }
90
+ CHAISCRIPT_CONSTEXPR bool is_arithmetic () const CHAISCRIPT_NOEXCEPT { return m_flags[is_arithmetic_flag] ; }
91
+ CHAISCRIPT_CONSTEXPR bool is_undef () const CHAISCRIPT_NOEXCEPT { return m_flags[is_undef_flag] ; }
92
+ CHAISCRIPT_CONSTEXPR bool is_pointer () const CHAISCRIPT_NOEXCEPT { return m_flags[is_pointer_flag] ; }
92
93
93
94
std::string name () const
94
95
{
@@ -118,12 +119,13 @@ namespace chaiscript
118
119
private:
119
120
const std::type_info *m_type_info;
120
121
const std::type_info *m_bare_type_info;
121
- bool m_is_const;
122
- bool m_is_reference;
123
- bool m_is_pointer;
124
- bool m_is_void;
125
- bool m_is_arithmetic;
126
- bool m_is_undef;
122
+ std::bitset<6 > m_flags;
123
+ static const int is_const_flag = 0 ;
124
+ static const int is_reference_flag = 1 ;
125
+ static const int is_pointer_flag = 2 ;
126
+ static const int is_void_flag = 3 ;
127
+ static const int is_arithmetic_flag = 4 ;
128
+ static const int is_undef_flag = 5 ;
127
129
};
128
130
129
131
namespace detail
0 commit comments