提交 6443fea5 编写于 作者: fengqikai1414's avatar fengqikai1414 提交者: zhangchaoltt

cyber: make DEFINE_TYPE_TRAITS more readale

上级 2bf79c1f
...@@ -30,20 +30,22 @@ ...@@ -30,20 +30,22 @@
#define CACHELINE_SIZE 64 #define CACHELINE_SIZE 64
#define DEFINE_TYPE_TRAIT(name, func) \ #define DEFINE_TYPE_TRAIT(name, func) \
template <typename T> \ template <typename T> \
class name { \ struct name { \
private: \ template <typename Class> \
template <typename Class> \ static constexpr bool Test(decltype(&Class::func)*) { \
static char Test(decltype(&Class::func)*); \ return true; \
template <typename> \ } \
static int Test(...); \ template <typename> \
\ static constexpr bool Test(...) { \
public: \ return false; \
static constexpr bool value = sizeof(Test<T>(nullptr)) == 1; \ } \
}; \ \
\ static constexpr bool value = Test<T>(nullptr); \
template <typename T> \ }; \
\
template <typename T> \
constexpr bool name<T>::value; constexpr bool name<T>::value;
inline void cpu_relax() { inline void cpu_relax() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册