Use a bitset instead of bools for type_info flags
This commit is contained in:
parent
bc388e59da
commit
8496a86043
@ -11,6 +11,7 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <bitset>
|
||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
@ -32,17 +33,17 @@ namespace chaiscript
|
|||||||
CHAISCRIPT_CONSTEXPR Type_Info(bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void,
|
CHAISCRIPT_CONSTEXPR Type_Info(bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void,
|
||||||
bool t_is_arithmetic, const std::type_info *t_ti, const std::type_info *t_bare_ti)
|
bool t_is_arithmetic, const std::type_info *t_ti, const std::type_info *t_bare_ti)
|
||||||
: m_type_info(t_ti), m_bare_type_info(t_bare_ti),
|
: m_type_info(t_ti), m_bare_type_info(t_bare_ti),
|
||||||
m_is_const(t_is_const), m_is_reference(t_is_reference), m_is_pointer(t_is_pointer),
|
m_flags((t_is_const << is_const_flag)
|
||||||
m_is_void(t_is_void), m_is_arithmetic(t_is_arithmetic),
|
+ (t_is_reference << is_reference_flag)
|
||||||
m_is_undef(false)
|
+ (t_is_pointer << is_pointer_flag)
|
||||||
|
+ (t_is_void << is_void_flag)
|
||||||
|
+ (t_is_arithmetic << is_arithmetic_flag))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CHAISCRIPT_CONSTEXPR Type_Info()
|
CHAISCRIPT_CONSTEXPR Type_Info()
|
||||||
: m_type_info(nullptr), m_bare_type_info(nullptr),
|
: m_type_info(nullptr), m_bare_type_info(nullptr),
|
||||||
m_is_const(false), m_is_reference(false), m_is_pointer(false),
|
m_flags(1 << is_undef_flag)
|
||||||
m_is_void(false), m_is_arithmetic(false),
|
|
||||||
m_is_undef(true)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,12 +84,12 @@ namespace chaiscript
|
|||||||
&& (*m_bare_type_info) == ti;
|
&& (*m_bare_type_info) == ti;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHAISCRIPT_CONSTEXPR bool is_const() const CHAISCRIPT_NOEXCEPT { return m_is_const; }
|
CHAISCRIPT_CONSTEXPR bool is_const() const CHAISCRIPT_NOEXCEPT { return m_flags[is_const_flag]; }
|
||||||
CHAISCRIPT_CONSTEXPR bool is_reference() const CHAISCRIPT_NOEXCEPT { return m_is_reference; }
|
CHAISCRIPT_CONSTEXPR bool is_reference() const CHAISCRIPT_NOEXCEPT { return m_flags[is_reference_flag]; }
|
||||||
CHAISCRIPT_CONSTEXPR bool is_void() const CHAISCRIPT_NOEXCEPT { return m_is_void; }
|
CHAISCRIPT_CONSTEXPR bool is_void() const CHAISCRIPT_NOEXCEPT { return m_flags[is_void_flag]; }
|
||||||
CHAISCRIPT_CONSTEXPR bool is_arithmetic() const CHAISCRIPT_NOEXCEPT { return m_is_arithmetic; }
|
CHAISCRIPT_CONSTEXPR bool is_arithmetic() const CHAISCRIPT_NOEXCEPT { return m_flags[is_arithmetic_flag]; }
|
||||||
CHAISCRIPT_CONSTEXPR bool is_undef() const CHAISCRIPT_NOEXCEPT { return m_is_undef; }
|
CHAISCRIPT_CONSTEXPR bool is_undef() const CHAISCRIPT_NOEXCEPT { return m_flags[is_undef_flag]; }
|
||||||
CHAISCRIPT_CONSTEXPR bool is_pointer() const CHAISCRIPT_NOEXCEPT { return m_is_pointer; }
|
CHAISCRIPT_CONSTEXPR bool is_pointer() const CHAISCRIPT_NOEXCEPT { return m_flags[is_pointer_flag]; }
|
||||||
|
|
||||||
std::string name() const
|
std::string name() const
|
||||||
{
|
{
|
||||||
@ -118,12 +119,13 @@ namespace chaiscript
|
|||||||
private:
|
private:
|
||||||
const std::type_info *m_type_info;
|
const std::type_info *m_type_info;
|
||||||
const std::type_info *m_bare_type_info;
|
const std::type_info *m_bare_type_info;
|
||||||
bool m_is_const;
|
std::bitset<6> m_flags;
|
||||||
bool m_is_reference;
|
static const int is_const_flag = 0;
|
||||||
bool m_is_pointer;
|
static const int is_reference_flag = 1;
|
||||||
bool m_is_void;
|
static const int is_pointer_flag = 2;
|
||||||
bool m_is_arithmetic;
|
static const int is_void_flag = 3;
|
||||||
bool m_is_undef;
|
static const int is_arithmetic_flag = 4;
|
||||||
|
static const int is_undef_flag = 5;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
|
Loading…
x
Reference in New Issue
Block a user