ソースを参照

AK: Add a Conditional<condition, TrueType, FalseType> template

This allows you to select a type based on a compile-time condition.
Andreas Kling 5 年 前
コミット
b98d8ad5b0
1 ファイル変更11 行追加0 行削除
  1. 11 0
      AK/StdLibExtras.h

+ 11 - 0
AK/StdLibExtras.h

@@ -320,8 +320,19 @@ struct IsSame<T, T> {
     };
     };
 };
 };
 
 
+template<bool condition, class TrueType, class FalseType>
+struct Conditional {
+    typedef TrueType Type;
+};
+
+template<class TrueType, class FalseType>
+struct Conditional<false, TrueType, FalseType> {
+    typedef FalseType Type;
+};
+
 }
 }
 
 
+using AK::Conditional;
 using AK::ceil_div;
 using AK::ceil_div;
 using AK::clamp;
 using AK::clamp;
 using AK::exchange;
 using AK::exchange;