Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add additional type_traits methods #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions jitify.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1709,6 +1709,20 @@ static const char* jitsafe_header_type_traits = R"(
template<class Ret, class... Args> struct is_function<Ret(Args...)> : true_type {}; //regular
template<class Ret, class... Args> struct is_function<Ret(Args......)> : true_type {}; // variadic

template<typename T> struct make_signed { typedef T type; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a specialization for bool with no implementation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also can you add a TODO noting that there are more complicated rules for enums, char, wchar_t etc. that aren't implemented here.

template<> struct make_signed<unsigned char> { typedef signed char type; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a separate specialization for char (which is a distinct type and not necessarily signed or unsigned).

template<> struct make_signed<unsigned short> { typedef signed short type; };
template<> struct make_signed<unsigned int> { typedef signed int type; };
template<> struct make_signed<unsigned long> { typedef signed long type; };
template<> struct make_signed<unsigned long long> { typedef signed long long type; };

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need specializations to preserve CV-qualifiers.

Suggested change
template<typename T> struct make_signed<const T> { typedef const typename make_signed<T>::type type; };
template<typename T> struct make_signed<volatile T> { typedef volatile typename make_signed<T>::type type; };
template<typename T> struct make_signed<const volatile T> { typedef const volatile typename make_signed<T>::type type; };

template<typename T> struct make_unsigned { typedef T type; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a specialization for bool with no implementation.

template<> struct make_unsigned<char> { typedef unsigned char type; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a separate specialization for signed char.

template<> struct make_unsigned<short> { typedef unsigned short type; };
template<> struct make_unsigned<int> { typedef unsigned int type; };
template<> struct make_unsigned<long> { typedef unsigned long type; };
template<> struct make_unsigned<long long> { typedef unsigned long long type; };

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need specializations to preserve CV-qualifiers.

Suggested change
template<typename T> struct make_unsigned<const T> { typedef const typename make_unsigned<T>::type type; };
template<typename T> struct make_unsigned<volatile T> { typedef volatile typename make_unsigned<T>::type type; };
template<typename T> struct make_unsigned<const volatile T> { typedef const volatile typename make_unsigned<T>::type type; };

template<class> struct result_of;
template<class F, typename... Args>
struct result_of<F(Args...)> {
Expand Down