Make type_info fully constexpr
- Minor hit in compile size - Minor improvement in runtime
This commit is contained in:
		@@ -29,8 +29,8 @@ namespace chaiscript
 | 
				
			|||||||
  class Type_Info
 | 
					  class Type_Info
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
      constexpr Type_Info(bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void, 
 | 
					      constexpr Type_Info(const bool t_is_const, const bool t_is_reference, const bool t_is_pointer, const bool t_is_void, 
 | 
				
			||||||
          bool t_is_arithmetic, const std::type_info *t_ti, const std::type_info *t_bare_ti)
 | 
					          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_type_info(t_ti), m_bare_type_info(t_bare_ti),
 | 
				
			||||||
          m_flags((static_cast<unsigned int>(t_is_const) << is_const_flag)
 | 
					          m_flags((static_cast<unsigned int>(t_is_const) << is_const_flag)
 | 
				
			||||||
                + (static_cast<unsigned int>(t_is_reference) << is_reference_flag)
 | 
					                + (static_cast<unsigned int>(t_is_reference) << is_reference_flag)
 | 
				
			||||||
@@ -121,9 +121,7 @@ namespace chaiscript
 | 
				
			|||||||
    template<typename T>
 | 
					    template<typename T>
 | 
				
			||||||
      struct Get_Type_Info
 | 
					      struct Get_Type_Info
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        typedef T type;
 | 
					        static constexpr Type_Info get()
 | 
				
			||||||
 | 
					 | 
				
			||||||
        static Type_Info get()
 | 
					 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          return Type_Info(std::is_const<typename std::remove_pointer<typename std::remove_reference<T>::type>::type>::value, 
 | 
					          return Type_Info(std::is_const<typename std::remove_pointer<typename std::remove_reference<T>::type>::type>::value, 
 | 
				
			||||||
              std::is_reference<T>::value, std::is_pointer<T>::value, 
 | 
					              std::is_reference<T>::value, std::is_pointer<T>::value, 
 | 
				
			||||||
@@ -138,9 +136,9 @@ namespace chaiscript
 | 
				
			|||||||
    template<typename T>
 | 
					    template<typename T>
 | 
				
			||||||
      struct Get_Type_Info<std::shared_ptr<T> >
 | 
					      struct Get_Type_Info<std::shared_ptr<T> >
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        typedef T type;
 | 
					//        typedef T type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        static Type_Info get()
 | 
					        static constexpr Type_Info get()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value, 
 | 
					          return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value, 
 | 
				
			||||||
              std::is_void<T>::value,
 | 
					              std::is_void<T>::value,
 | 
				
			||||||
@@ -158,9 +156,7 @@ namespace chaiscript
 | 
				
			|||||||
    template<typename T>
 | 
					    template<typename T>
 | 
				
			||||||
      struct Get_Type_Info<const std::shared_ptr<T> &>
 | 
					      struct Get_Type_Info<const std::shared_ptr<T> &>
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        typedef T type;
 | 
					        static constexpr Type_Info get()
 | 
				
			||||||
 | 
					 | 
				
			||||||
        static Type_Info get()
 | 
					 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value, 
 | 
					          return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value, 
 | 
				
			||||||
              std::is_void<T>::value,
 | 
					              std::is_void<T>::value,
 | 
				
			||||||
@@ -173,9 +169,7 @@ namespace chaiscript
 | 
				
			|||||||
    template<typename T>
 | 
					    template<typename T>
 | 
				
			||||||
      struct Get_Type_Info<std::reference_wrapper<T> >
 | 
					      struct Get_Type_Info<std::reference_wrapper<T> >
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        typedef T type;
 | 
					        static constexpr Type_Info get()
 | 
				
			||||||
 | 
					 | 
				
			||||||
        static Type_Info get()
 | 
					 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value, 
 | 
					          return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value, 
 | 
				
			||||||
              std::is_void<T>::value,
 | 
					              std::is_void<T>::value,
 | 
				
			||||||
@@ -188,9 +182,7 @@ namespace chaiscript
 | 
				
			|||||||
    template<typename T>
 | 
					    template<typename T>
 | 
				
			||||||
      struct Get_Type_Info<const std::reference_wrapper<T> &>
 | 
					      struct Get_Type_Info<const std::reference_wrapper<T> &>
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        typedef T type;
 | 
					        static constexpr Type_Info get()
 | 
				
			||||||
 | 
					 | 
				
			||||||
        static Type_Info get()
 | 
					 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value, 
 | 
					          return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value, 
 | 
				
			||||||
              std::is_void<T>::value,
 | 
					              std::is_void<T>::value,
 | 
				
			||||||
@@ -212,7 +204,7 @@ namespace chaiscript
 | 
				
			|||||||
  /// chaiscript::Type_Info ti = chaiscript::user_type(i);
 | 
					  /// chaiscript::Type_Info ti = chaiscript::user_type(i);
 | 
				
			||||||
  /// \endcode
 | 
					  /// \endcode
 | 
				
			||||||
  template<typename T>
 | 
					  template<typename T>
 | 
				
			||||||
   Type_Info user_type(const T &/*t*/)
 | 
					  constexpr Type_Info user_type(const T &/*t*/)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    return detail::Get_Type_Info<T>::get();
 | 
					    return detail::Get_Type_Info<T>::get();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -227,7 +219,7 @@ namespace chaiscript
 | 
				
			|||||||
  /// chaiscript::Type_Info ti = chaiscript::user_type<int>();
 | 
					  /// chaiscript::Type_Info ti = chaiscript::user_type<int>();
 | 
				
			||||||
  /// \endcode
 | 
					  /// \endcode
 | 
				
			||||||
  template<typename T>
 | 
					  template<typename T>
 | 
				
			||||||
   Type_Info user_type()
 | 
					  constexpr Type_Info user_type()
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    return detail::Get_Type_Info<T>::get();
 | 
					    return detail::Get_Type_Info<T>::get();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user