Try out some alias templates for cleanup

This commit is contained in:
Jason Turner 2014-09-18 20:48:34 -06:00
parent 04782b6a33
commit 93c1cfde99
2 changed files with 8 additions and 19 deletions

View File

@ -86,7 +86,7 @@ namespace chaiscript
#pragma warning(disable : 4127) #pragma warning(disable : 4127)
#endif #endif
if (std::is_polymorphic<typename detail::Stripped_Type<Type>::type>::value && t_conversions) if (std::is_polymorphic<Bare_Type<Type>>::value && t_conversions)
{ {
try { try {
// std::cout << "trying an up conversion " << typeid(Type).name() << std::endl; // std::cout << "trying an up conversion " << typeid(Type).name() << std::endl;

View File

@ -16,14 +16,8 @@
namespace chaiscript namespace chaiscript
{ {
namespace detail
{
template<typename T> template<typename T>
struct Bare_Type using Bare_Type = typename std::remove_cv<typename std::remove_pointer<typename std::remove_reference<T>::type>::type>::type;
{
typedef typename std::remove_cv<typename std::remove_pointer<typename std::remove_reference<T>::type>::type>::type type;
};
}
/// \brief Compile time deduced information about a type /// \brief Compile time deduced information about a type
class Type_Info class Type_Info
@ -151,7 +145,7 @@ namespace chaiscript
std::is_void<T>::value, std::is_void<T>::value,
std::is_arithmetic<T>::value && !std::is_same<typename std::remove_const<T>::type, bool>::value, std::is_arithmetic<T>::value && !std::is_same<typename std::remove_const<T>::type, bool>::value,
&typeid(T), &typeid(T),
&typeid(typename Bare_Type<T>::type)); &typeid(Bare_Type<T>));
} }
}; };
@ -166,7 +160,7 @@ namespace chaiscript
std::is_void<T>::value, std::is_void<T>::value,
std::is_arithmetic<T>::value && !std::is_same<typename std::remove_const<T>::type, bool>::value, std::is_arithmetic<T>::value && !std::is_same<typename std::remove_const<T>::type, bool>::value,
&typeid(std::shared_ptr<T> ), &typeid(std::shared_ptr<T> ),
&typeid(typename Bare_Type<T>::type)); &typeid(Bare_Type<T>));
} }
}; };
@ -181,7 +175,7 @@ namespace chaiscript
std::is_void<T>::value, std::is_void<T>::value,
std::is_arithmetic<T>::value && !std::is_same<typename std::remove_const<T>::type, bool>::value, std::is_arithmetic<T>::value && !std::is_same<typename std::remove_const<T>::type, bool>::value,
&typeid(const std::shared_ptr<T> &), &typeid(const std::shared_ptr<T> &),
&typeid(typename Bare_Type<T>::type)); &typeid(Bare_Type<T>));
} }
}; };
@ -196,7 +190,7 @@ namespace chaiscript
std::is_void<T>::value, std::is_void<T>::value,
std::is_arithmetic<T>::value && !std::is_same<typename std::remove_const<T>::type, bool>::value, std::is_arithmetic<T>::value && !std::is_same<typename std::remove_const<T>::type, bool>::value,
&typeid(std::reference_wrapper<T> ), &typeid(std::reference_wrapper<T> ),
&typeid(typename Bare_Type<T>::type)); &typeid(Bare_Type<T>));
} }
}; };
@ -211,15 +205,10 @@ namespace chaiscript
std::is_void<T>::value, std::is_void<T>::value,
std::is_arithmetic<T>::value && !std::is_same<typename std::remove_const<T>::type, bool>::value, std::is_arithmetic<T>::value && !std::is_same<typename std::remove_const<T>::type, bool>::value,
&typeid(const std::reference_wrapper<T> &), &typeid(const std::reference_wrapper<T> &),
&typeid(typename Bare_Type<T>::type)); &typeid(Bare_Type<T>));
} }
}; };
template<typename T>
struct Stripped_Type
{
typedef typename Bare_Type<typename detail::Get_Type_Info<T>::type>::type type;
};
} }
/// \brief Creates a Type_Info object representing the type passed in /// \brief Creates a Type_Info object representing the type passed in