From 80cc18bf2f901fdc2c34c5bbce78ec272fdd9821 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sun, 17 Apr 2016 08:15:24 -0600 Subject: [PATCH] Make type_info fully constexpr - Minor hit in compile size - Minor improvement in runtime --- include/chaiscript/dispatchkit/type_info.hpp | 28 +++++++------------- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/include/chaiscript/dispatchkit/type_info.hpp b/include/chaiscript/dispatchkit/type_info.hpp index 9dfdb8f0..664e4d3c 100644 --- a/include/chaiscript/dispatchkit/type_info.hpp +++ b/include/chaiscript/dispatchkit/type_info.hpp @@ -29,8 +29,8 @@ namespace chaiscript class Type_Info { public: - 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) + 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) : m_type_info(t_ti), m_bare_type_info(t_bare_ti), m_flags((static_cast(t_is_const) << is_const_flag) + (static_cast(t_is_reference) << is_reference_flag) @@ -121,9 +121,7 @@ namespace chaiscript template struct Get_Type_Info { - typedef T type; - - static Type_Info get() + static constexpr Type_Info get() { return Type_Info(std::is_const::type>::type>::value, std::is_reference::value, std::is_pointer::value, @@ -138,9 +136,9 @@ namespace chaiscript template struct Get_Type_Info > { - typedef T type; +// typedef T type; - static Type_Info get() + static constexpr Type_Info get() { return Type_Info(std::is_const::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, @@ -158,9 +156,7 @@ namespace chaiscript template struct Get_Type_Info &> { - typedef T type; - - static Type_Info get() + static constexpr Type_Info get() { return Type_Info(std::is_const::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, @@ -173,9 +169,7 @@ namespace chaiscript template struct Get_Type_Info > { - typedef T type; - - static Type_Info get() + static constexpr Type_Info get() { return Type_Info(std::is_const::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, @@ -188,9 +182,7 @@ namespace chaiscript template struct Get_Type_Info &> { - typedef T type; - - static Type_Info get() + static constexpr Type_Info get() { return Type_Info(std::is_const::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, @@ -212,7 +204,7 @@ namespace chaiscript /// chaiscript::Type_Info ti = chaiscript::user_type(i); /// \endcode template - Type_Info user_type(const T &/*t*/) + constexpr Type_Info user_type(const T &/*t*/) { return detail::Get_Type_Info::get(); } @@ -227,7 +219,7 @@ namespace chaiscript /// chaiscript::Type_Info ti = chaiscript::user_type(); /// \endcode template - Type_Info user_type() + constexpr Type_Info user_type() { return detail::Get_Type_Info::get(); }