Updated:

less than 1 minute read

개요

  • conjunction
    • and 연산을 효과적으로 수행
  • disjunction
    • or 연산을 효과적으로 수행
  • negation
    • 부정 연산 수행


예제

  • 코드
     #include <iostream>
        
     using namespace std;
        
     template <typename T, typename... Ts> void func(T, Ts...) {
     	if (conjunction<is_same<T, Ts>...>::value) {
     		cout << "conjunction" << endl;
     	}
        
     	if (disjunction<is_same<T, Ts>...>::value) {
     		cout << "disjunction" << endl;
     	}
     }
        
     int main() {
     	func(1, 2, 3);
        
     	cout << "------ 1" << endl;
        
     	func(1, "a");
        
     	cout << "------ 2" << endl;
        
     	func(1, 2, "a");
        
     	cout << "------ 3" << endl;
        
     	cout << negation<bool_constant<true>>::value << endl;
     	cout << negation<bool_constant<false>>::value << endl;
        
     	return 0;
     }
    
  • 실행 결과
     conjunction
     disjunction
     ------ 1
     ------ 2
     disjunction
     ------ 3
     0
     1