C++11编程实践:实现编译期的“或”运算
#include <type_traits>using namespace std;template<bool C, typename... Rest>struct or_impl : true_type{};template<typename Second, typename... Rest>struct or_impl<false, Second, Rest...> : or_impl<Second::value, Rest...>{};template<>struct or_impl<false> : false_type{};template<typename First, typename Second, typename... Rest>struct or_ : or_impl<First::value, Second, Rest...>{};int main(){struct unknown;static_assert(or_<true_type, true_type>::value, "error");static_assert(or_<false_type, true_type>::value, "error");static_assert(or_<true_type, false_type>::value, "error");static_assert(!or_<false_type, false_type>::value, "error");static_assert(or_<true_type, unknown>::value, "error");static_assert(or_<true_type, unknown, unknown>::value, "error");}