11#ifndef CHAISCRIPT_TYPE_INFO_HPP_
12#define CHAISCRIPT_TYPE_INFO_HPP_
27 typedef typename std::remove_cv<typename std::remove_pointer<typename std::remove_reference<T>::type>
::type>
::type type;
36 constexpr Type_Info(
const bool t_is_const,
const bool t_is_reference,
const bool t_is_pointer,
const bool t_is_void,
37 const bool t_is_arithmetic,
const std::type_info *t_ti,
const std::type_info *t_bare_ti)
38 : m_type_info(t_ti), m_bare_type_info(t_bare_ti),
39 m_flags((static_cast<unsigned int>(t_is_const) << is_const_flag)
40 + (static_cast<unsigned int>(t_is_reference) << is_reference_flag)
41 + (static_cast<unsigned int>(t_is_pointer) << is_pointer_flag)
42 + (static_cast<unsigned int>(t_is_void) << is_void_flag)
43 + (static_cast<unsigned int>(t_is_arithmetic) << is_arithmetic_flag))
51 return m_type_info->before(*ti.m_type_info);
59 constexpr bool operator!=(
const std::type_info &ti)
const noexcept
66 return ti.m_type_info == m_type_info
67 || *ti.m_type_info == *m_type_info;
70 constexpr bool operator==(
const std::type_info &ti)
const noexcept
72 return !
is_undef() && (*m_type_info) == ti;
77 return ti.m_bare_type_info == m_bare_type_info
78 || *ti.m_bare_type_info == *m_bare_type_info;
83 return !
is_undef() && (*m_bare_type_info) == ti;
86 constexpr bool is_const() const noexcept {
return (m_flags & (1 << is_const_flag)) != 0; }
87 constexpr bool is_reference() const noexcept {
return (m_flags & (1 << is_reference_flag)) != 0; }
88 constexpr bool is_void() const noexcept {
return (m_flags & (1 << is_void_flag)) != 0; }
89 constexpr bool is_arithmetic() const noexcept {
return (m_flags & (1 << is_arithmetic_flag)) != 0; }
90 constexpr bool is_undef() const noexcept {
return (m_flags & (1 << is_undef_flag)) != 0; }
91 constexpr bool is_pointer() const noexcept {
return (m_flags & (1 << is_pointer_flag)) != 0; }
97 return m_type_info->name();
107 return m_bare_type_info->name();
115 return m_bare_type_info;
119 struct Unknown_Type {};
121 const std::type_info *m_type_info = &
typeid(Unknown_Type);
122 const std::type_info *m_bare_type_info = &
typeid(Unknown_Type);
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;
129 unsigned int m_flags = (1 << is_undef_flag);
140 return Type_Info(std::is_const<
typename std::remove_pointer<
typename std::remove_reference<T>::type>::type>::value,
141 std::is_reference<T>::value, std::is_pointer<T>::value,
142 std::is_void<T>::value,
143 (std::is_arithmetic<T>::value || std::is_arithmetic<
typename std::remove_reference<T>::type>::value)
144 && !std::is_same<
typename std::remove_const<
typename std::remove_reference<T>::type>::type,
bool>::value,
157 return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value,
158 std::is_void<T>::value,
159 std::is_arithmetic<T>::value && !std::is_same<
typename std::remove_const<
typename std::remove_reference<T>::type>::type,
bool>::value,
160 &
typeid(std::shared_ptr<T> ),
175 return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value,
176 std::is_void<T>::value,
177 std::is_arithmetic<T>::value && !std::is_same<
typename std::remove_const<
typename std::remove_reference<T>::type>::type,
bool>::value,
178 &
typeid(
const std::shared_ptr<T> &),
188 return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value,
189 std::is_void<T>::value,
190 std::is_arithmetic<T>::value && !std::is_same<
typename std::remove_const<
typename std::remove_reference<T>::type>::type,
bool>::value,
191 &
typeid(std::reference_wrapper<T> ),
201 return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value,
202 std::is_void<T>::value,
203 std::is_arithmetic<T>::value && !std::is_same<
typename std::remove_const<
typename std::remove_reference<T>::type>::type,
bool>::value,
204 &
typeid(
const std::reference_wrapper<T> &),
Compile time deduced information about a type.
Definition type_info.hpp:34
constexpr bool is_const() const noexcept
Definition type_info.hpp:86
constexpr bool operator!=(const Type_Info &ti) const noexcept
Definition type_info.hpp:54
bool operator<(const Type_Info &ti) const noexcept
Definition type_info.hpp:49
constexpr bool bare_equal_type_info(const std::type_info &ti) const noexcept
Definition type_info.hpp:81
constexpr const std::type_info * bare_type_info() const
Definition type_info.hpp:113
constexpr bool operator==(const std::type_info &ti) const noexcept
Definition type_info.hpp:70
constexpr Type_Info()=default
std::string name() const
Definition type_info.hpp:93
constexpr bool operator!=(const std::type_info &ti) const noexcept
Definition type_info.hpp:59
constexpr bool is_void() const noexcept
Definition type_info.hpp:88
constexpr Type_Info(const bool t_is_const, const bool t_is_reference, const bool t_is_pointer, const bool t_is_void, const bool t_is_arithmetic, const std::type_info *t_ti, const std::type_info *t_bare_ti)
Definition type_info.hpp:36
constexpr bool is_reference() const noexcept
Definition type_info.hpp:87
constexpr bool is_undef() const noexcept
Definition type_info.hpp:90
std::string bare_name() const
Definition type_info.hpp:103
constexpr bool is_arithmetic() const noexcept
Definition type_info.hpp:89
constexpr bool bare_equal(const Type_Info &ti) const noexcept
Definition type_info.hpp:75
constexpr bool is_pointer() const noexcept
Definition type_info.hpp:91
constexpr bool operator==(const Type_Info &ti) const noexcept
Definition type_info.hpp:64
Classes and functions reserved for internal use. Items in this namespace are not supported.
Namespace chaiscript contains every API call that the average user will be concerned with.
constexpr Type_Info user_type()
Creates a Type_Info object representing the templated type.
Definition type_info.hpp:236
Definition type_info.hpp:26
std::remove_cv< typenamestd::remove_pointer< typenamestd::remove_reference< T >::type >::type >::type type
Definition type_info.hpp:27
static constexpr Type_Info get()
Definition type_info.hpp:199
static constexpr Type_Info get()
Definition type_info.hpp:173
static constexpr Type_Info get()
Definition type_info.hpp:186
static constexpr Type_Info get()
Definition type_info.hpp:155
Helper used to create a Type_Info object.
Definition type_info.hpp:137
static constexpr Type_Info get()
Definition type_info.hpp:138