Commit 3c3d701e authored by Astha Rai's avatar Astha Rai
Browse files

updated functionality in type utility file

parent 1694c70c
...@@ -68,7 +68,6 @@ struct remove_reference<T&&> ...@@ -68,7 +68,6 @@ struct remove_reference<T&&>
{ {
typedef T type; typedef T type;
}; };
template <class T> template <class T>
struct remove_pointer struct remove_pointer
{ {
...@@ -94,33 +93,62 @@ struct remove_pointer<T* const volatile> ...@@ -94,33 +93,62 @@ struct remove_pointer<T* const volatile>
{ {
typedef T type; typedef T type;
}; };
template <class T>
struct remove_const
{
typedef T type;
};
template <class T>
struct remove_const<const T>
{
typedef T type;
};
template <typename T> template <typename T>
constexpr T&& forward(typename remove_reference<T>::type& t_) noexcept constexpr T&& forward(typename remove_reference<T>::type& t_) noexcept
{ {
return static_cast<T&&>(t_); return static_cast<T&&>(t_);
} }
template <typename T> template <typename T>
constexpr T&& forward(typename remove_reference<T>::type&& t_) noexcept constexpr T&& forward(typename remove_reference<T>::type&& t_) noexcept
{ {
return static_cast<T&&>(t_); return static_cast<T&&>(t_);
} }
template <class T>
struct is_const : public integral_constant<bool, false>
{
};
template <class T>
struct is_const<const T> : public integral_constant<bool, true>
{
};
template <class T>
inline constexpr bool is_const_v = is_const<T>::value;
template <typename T> template <typename T>
T&& declval() noexcept; inline constexpr bool is_reference_v = is_reference<T>::value;
template <class T>
struct remove_const
{
typedef T type;
};
template <class T>
struct remove_const<const T>
{
typedef T type;
};
template <class T>
using remove_const_t = typename remove_const<T>::type;
template <class T>
inline constexpr bool is_class_v = is_class<T>::value;
template <class T>
inline constexpr bool is_trivially_copyable_v = is_trivially_copyable<T>::value;
// template <typename T>
// T&& declval() noexcept;
template <class T, class U = T&&>
U private_declval(int);
template <class T>
T private_declval(long);
template <class T>
auto declval() noexcept -> decltype(private_declval<T>(0));
template <typename... Ts> template <class...>
using void_t = void; using void_t = void;
#else #else
#include <utility> #include <utility>
...@@ -129,9 +157,13 @@ using std::declval; ...@@ -129,9 +157,13 @@ using std::declval;
using std::forward; using std::forward;
using std::is_base_of; using std::is_base_of;
using std::is_class; using std::is_class;
using std::is_class_v;
using std::is_const_v;
using std::is_pointer; using std::is_pointer;
using std::is_reference; using std::is_reference;
using std::is_reference_v;
using std::is_trivially_copyable; using std::is_trivially_copyable;
using std::is_trivially_copyable_v;
using std::is_unsigned; using std::is_unsigned;
using std::remove_const; using std::remove_const;
using std::remove_cv; using std::remove_cv;
...@@ -150,16 +182,6 @@ struct is_same<X, X> : public integral_constant<bool, true> ...@@ -150,16 +182,6 @@ struct is_same<X, X> : public integral_constant<bool, true>
{ {
}; };
template <typename X>
struct is_const : public integral_constant<bool, false>
{
};
template <typename X>
struct is_const<const X> : public integral_constant<bool, true>
{
};
template <typename X> template <typename X>
struct is_floating_point : public integral_constant<bool, false> struct is_floating_point : public integral_constant<bool, false>
{ {
...@@ -174,7 +196,6 @@ template <> ...@@ -174,7 +196,6 @@ template <>
struct is_floating_point<double> : public integral_constant<bool, true> struct is_floating_point<double> : public integral_constant<bool, true>
{ {
}; };
template <> template <>
struct is_floating_point<long double> : public integral_constant<bool, true> struct is_floating_point<long double> : public integral_constant<bool, true>
{ {
...@@ -209,7 +230,6 @@ template <> ...@@ -209,7 +230,6 @@ template <>
struct is_integral<short> : public integral_constant<bool, true> struct is_integral<short> : public integral_constant<bool, true>
{ {
}; };
template <> template <>
struct is_integral<unsigned short> : public integral_constant<bool, true> struct is_integral<unsigned short> : public integral_constant<bool, true>
{ {
...@@ -244,7 +264,6 @@ template <> ...@@ -244,7 +264,6 @@ template <>
struct is_integral<wchar_t> : public integral_constant<bool, true> struct is_integral<wchar_t> : public integral_constant<bool, true>
{ {
}; };
template <> template <>
struct is_integral<char16_t> : public integral_constant<bool, true> struct is_integral<char16_t> : public integral_constant<bool, true>
{ {
...@@ -260,15 +279,9 @@ struct is_integral<bool> : public integral_constant<bool, true> ...@@ -260,15 +279,9 @@ struct is_integral<bool> : public integral_constant<bool, true>
{ {
}; };
template <typename T>
inline constexpr bool is_reference_v = is_reference<T>::value;
template <typename X, typename Y> template <typename X, typename Y>
inline constexpr bool is_same_v = is_same<X, Y>::value; inline constexpr bool is_same_v = is_same<X, Y>::value;
template <typename X>
inline constexpr bool is_const_v = is_const<X>::value;
template <typename X, typename Y> template <typename X, typename Y>
inline constexpr bool is_base_of_v = is_base_of<X, Y>::value; inline constexpr bool is_base_of_v = is_base_of<X, Y>::value;
...@@ -283,16 +296,12 @@ using remove_reference_t = typename remove_reference<T>::type; ...@@ -283,16 +296,12 @@ using remove_reference_t = typename remove_reference<T>::type;
template <typename T> template <typename T>
using remove_cv_t = typename remove_cv<T>::type; using remove_cv_t = typename remove_cv<T>::type;
template <typename T> template <typename T>
using remove_cvref_t = remove_cv_t<remove_reference_t<T>>; using remove_cvref_t = remove_cv_t<remove_reference_t<T>>;
template <typename T> template <typename T>
using remove_pointer_t = typename remove_pointer<T>::type; using remove_pointer_t = typename remove_pointer<T>::type;
template <typename T>
using remove_const_t = typename remove_const<T>::type;
template <typename T> template <typename T>
inline constexpr bool is_pointer_v = is_pointer<T>::value; inline constexpr bool is_pointer_v = is_pointer<T>::value;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment