Created
January 7, 2018 19:19
-
-
Save nathiss/075a17368715406d6b434edb85e4ec2e to your computer and use it in GitHub Desktop.
Template for checking if two types are the same (C++).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _SAME_H | |
#define _SAME_H | |
template <bool C> | |
struct bool_type { | |
static constexpr bool value = C; | |
}; | |
using true_type = bool_type<true>; | |
using false_type = bool_type<false>; | |
template <typename T, typename U> | |
struct is_same : false_type {}; | |
template <typename T> | |
struct is_same<T, T> : true_type {}; | |
#endif // _SAME_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment