提交 e32bf397 编写于 作者: B Behdad Esfahbod

[meta] Add enable_if

上级 e76a3cae
......@@ -30,6 +30,11 @@
#include "hb.hh"
/*
* C++ Template Meta-programming.
*/
/* Void! For when we need a expression-type of void. */
struct hb_void_t { typedef void value; };
......@@ -37,4 +42,15 @@ struct hb_true_t { enum { value = true }; };
struct hb_false_t { enum { value = false }; };
template<bool B, class T = void>
struct hb_enable_if {};
template<class T>
struct hb_enable_if<true, T> { typedef T type; };
#define hb_enable_if(Cond) hb_enable_if<Code>::type* = nullptr
#define hb_enable_if_t(Type, Cond) hb_enable_if<(Cond), Type>::type
#endif /* HB_META_HH */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册