Move metaprogramming utils out of deDefs.

Change-Id: I67705c3c799d9bdc88a5c1823b55428a7aaa8fd5
diff --git a/Android.mk b/Android.mk
index 99fd19f..2868a95 100644
--- a/Android.mk
+++ b/Android.mk
@@ -87,6 +87,7 @@
 	framework/delibs/decpp/deDynamicLibrary.cpp \
 	framework/delibs/decpp/deFilePath.cpp \
 	framework/delibs/decpp/deMemPool.cpp \
+	framework/delibs/decpp/deMeta.cpp \
 	framework/delibs/decpp/deMutex.cpp \
 	framework/delibs/decpp/dePoolArray.cpp \
 	framework/delibs/decpp/dePoolString.cpp \
diff --git a/framework/delibs/decpp/CMakeLists.txt b/framework/delibs/decpp/CMakeLists.txt
index a585e50..f5120ef 100644
--- a/framework/delibs/decpp/CMakeLists.txt
+++ b/framework/delibs/decpp/CMakeLists.txt
@@ -23,6 +23,8 @@
 	deFilePath.hpp
 	deMemPool.cpp
 	deMemPool.hpp
+	deMeta.cpp
+	deMeta.hpp
 	deMutex.cpp
 	deMutex.hpp
 	dePoolArray.cpp
diff --git a/framework/delibs/decpp/deArrayUtil.hpp b/framework/delibs/decpp/deArrayUtil.hpp
index 0a7311e..4526c4a 100644
--- a/framework/delibs/decpp/deArrayUtil.hpp
+++ b/framework/delibs/decpp/deArrayUtil.hpp
@@ -24,13 +24,14 @@
  *//*--------------------------------------------------------------------*/
 
 #include "deDefs.hpp"
+#include "deMeta.hpp"
 
 namespace de
 {
 
 //! Get an element of an array with a specified size.
 template <int LastElementIndex, int Size, typename Elem>
-const Elem& getSizedArrayElement (const Elem (&array)[Size], typename de::EnableIf<int, LastElementIndex==Size>::Type offset)
+const Elem& getSizedArrayElement (const Elem (&array)[Size], typename de::meta::EnableIf<int, LastElementIndex==Size>::Type offset)
 {
 	DE_ASSERT(inBounds(offset, 0, Size));
 	return array[offset];
diff --git a/framework/delibs/decpp/deDefs.hpp b/framework/delibs/decpp/deDefs.hpp
index fe9b38b..73b84fb 100644
--- a/framework/delibs/decpp/deDefs.hpp
+++ b/framework/delibs/decpp/deDefs.hpp
@@ -71,17 +71,6 @@
 	inline void operator() (T* ptr) const { delete[] ptr; }
 };
 
-template <typename T, bool Cond>
-struct EnableIf
-{
-};
-
-template <typename T>
-struct EnableIf<T, true>
-{
-	typedef T Type;
-};
-
 } // de
 
 /*--------------------------------------------------------------------*//*!
diff --git a/framework/delibs/decpp/deMeta.cpp b/framework/delibs/decpp/deMeta.cpp
new file mode 100644
index 0000000..aad64a3
--- /dev/null
+++ b/framework/delibs/decpp/deMeta.cpp
@@ -0,0 +1,26 @@
+/*-------------------------------------------------------------------------
+ * drawElements C++ Base Library
+ * -----------------------------
+ *
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Metaprogramming tools
+ *//*--------------------------------------------------------------------*/
+
+#include "deMeta.hpp"
+
+DE_EMPTY_CPP_FILE
diff --git a/framework/delibs/decpp/deMeta.hpp b/framework/delibs/decpp/deMeta.hpp
new file mode 100644
index 0000000..231aac0
--- /dev/null
+++ b/framework/delibs/decpp/deMeta.hpp
@@ -0,0 +1,54 @@
+#ifndef _DEMETA_HPP
+#define _DEMETA_HPP
+/*-------------------------------------------------------------------------
+ * drawElements C++ Base Library
+ * -----------------------------
+ *
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Metaprogramming tools
+ *//*--------------------------------------------------------------------*/
+
+#include "deDefs.hpp"
+
+namespace de
+{
+namespace meta
+{
+
+template <typename T, bool Cond>
+struct EnableIf { };
+
+template <typename T>
+struct EnableIf<T, true>
+{
+	typedef T Type;
+};
+
+template <bool Cond>
+struct Not
+{
+	enum
+	{
+		Value = !Cond
+	};
+};
+
+} // meta
+} // de
+
+#endif // _DEMETA_HPP
diff --git a/modules/gles3/performance/es3pBufferDataUploadTests.cpp b/modules/gles3/performance/es3pBufferDataUploadTests.cpp
index 556f22c..d4dfa16 100644
--- a/modules/gles3/performance/es3pBufferDataUploadTests.cpp
+++ b/modules/gles3/performance/es3pBufferDataUploadTests.cpp
@@ -41,6 +41,7 @@
 #include "deRandom.hpp"
 #include "deMemory.h"
 #include "deThread.h"
+#include "deMeta.hpp"
 
 #include <algorithm>
 #include <iomanip>
@@ -57,6 +58,8 @@
 
 using gls::theilSenSiegelLinearRegression;
 using gls::LineParametersWithConfidence;
+using de::meta::EnableIf;
+using de::meta::Not;
 
 static const char* const s_dummyVertexShader =		"#version 300 es\n"
 													"in highp vec4 a_position;\n"
@@ -90,28 +93,6 @@
 													"	dEQP_FragColor = v_color;\n"
 													"}\n";
 
-template <typename TrueType, int cond>
-struct EnableIf
-{
-	typedef TrueType Type;
-};
-
-template <typename TrueType>
-struct EnableIf<TrueType, 0>
-{
-};
-
-template <typename TrueType, int cond>
-struct EnableIfNot
-{
-};
-
-template <typename TrueType>
-struct EnableIfNot<TrueType, 0>
-{
-	typedef TrueType Type;
-};
-
 struct SingleOperationDuration
 {
 	deUint64 totalDuration;
@@ -1159,35 +1140,35 @@
 }
 
 template <typename SampleType>
-static typename EnableIfNot<void, SampleTypeTraits<SampleType>::HAS_MAP_STATS>::Type logMapRangeStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats)
+static typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_MAP_STATS>::Value>::Type logMapRangeStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats)
 {
 	DE_UNREF(log);
 	DE_UNREF(stats);
 }
 
 template <typename SampleType>
-static typename EnableIfNot<void, SampleTypeTraits<SampleType>::HAS_UNMAP_STATS>::Type logUnmapStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats)
+static typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_UNMAP_STATS>::Value>::Type logUnmapStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats)
 {
 	DE_UNREF(log);
 	DE_UNREF(stats);
 }
 
 template <typename SampleType>
-static typename EnableIfNot<void, SampleTypeTraits<SampleType>::HAS_WRITE_STATS>::Type logWriteStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats)
+static typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_WRITE_STATS>::Value>::Type logWriteStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats)
 {
 	DE_UNREF(log);
 	DE_UNREF(stats);
 }
 
 template <typename SampleType>
-static typename EnableIfNot<void, SampleTypeTraits<SampleType>::HAS_FLUSH_STATS>::Type logFlushStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats)
+static typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_FLUSH_STATS>::Value>::Type logFlushStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats)
 {
 	DE_UNREF(log);
 	DE_UNREF(stats);
 }
 
 template <typename SampleType>
-static typename EnableIfNot<void, SampleTypeTraits<SampleType>::HAS_ALLOC_STATS>::Type logAllocStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats)
+static typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_ALLOC_STATS>::Value>::Type logAllocStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats)
 {
 	DE_UNREF(log);
 	DE_UNREF(stats);
@@ -1293,7 +1274,7 @@
 }
 
 template <typename SampleType>
-static typename EnableIfNot<void, SampleTypeTraits<SampleType>::HAS_MAP_STATS>::Type logMapContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
+static typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_MAP_STATS>::Value>::Type logMapContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
 {
 	DE_UNREF(log);
 	DE_UNREF(samples);
@@ -1301,7 +1282,7 @@
 }
 
 template <typename SampleType>
-static typename EnableIfNot<void, SampleTypeTraits<SampleType>::HAS_UNMAP_STATS>::Type logUnmapContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
+static typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_UNMAP_STATS>::Value>::Type logUnmapContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
 {
 	DE_UNREF(log);
 	DE_UNREF(samples);
@@ -1309,7 +1290,7 @@
 }
 
 template <typename SampleType>
-static typename EnableIfNot<void, SampleTypeTraits<SampleType>::HAS_WRITE_STATS>::Type logWriteContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
+static typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_WRITE_STATS>::Value>::Type logWriteContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
 {
 	DE_UNREF(log);
 	DE_UNREF(samples);
@@ -1317,7 +1298,7 @@
 }
 
 template <typename SampleType>
-static typename EnableIfNot<void, SampleTypeTraits<SampleType>::HAS_FLUSH_STATS>::Type logFlushContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
+static typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_FLUSH_STATS>::Value>::Type logFlushContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
 {
 	DE_UNREF(log);
 	DE_UNREF(samples);
@@ -1325,7 +1306,7 @@
 }
 
 template <typename SampleType>
-static typename EnableIfNot<void, SampleTypeTraits<SampleType>::HAS_ALLOC_STATS>::Type logAllocContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
+static typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_ALLOC_STATS>::Value>::Type logAllocContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
 {
 	DE_UNREF(log);
 	DE_UNREF(samples);
@@ -1333,7 +1314,7 @@
 }
 
 template <typename SampleType>
-static typename EnableIfNot<void, SampleTypeTraits<SampleType>::HAS_RENDER_STATS>::Type logRenderContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
+static typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_RENDER_STATS>::Value>::Type logRenderContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
 {
 	DE_UNREF(log);
 	DE_UNREF(samples);
@@ -1341,7 +1322,7 @@
 }
 
 template <typename SampleType>
-static typename EnableIfNot<void, SampleTypeTraits<SampleType>::HAS_READ_STATS>::Type logReadContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
+static typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_READ_STATS>::Value>::Type logReadContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
 {
 	DE_UNREF(log);
 	DE_UNREF(samples);
@@ -1349,7 +1330,7 @@
 }
 
 template <typename SampleType>
-static typename EnableIfNot<void, SampleTypeTraits<SampleType>::HAS_UPLOAD_STATS>::Type logUploadContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
+static typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_UPLOAD_STATS>::Value>::Type logUploadContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
 {
 	DE_UNREF(log);
 	DE_UNREF(samples);
@@ -1357,7 +1338,7 @@
 }
 
 template <typename SampleType>
-static typename EnableIfNot<void, SampleTypeTraits<SampleType>::HAS_TOTAL_STATS>::Type logTotalContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
+static typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_TOTAL_STATS>::Value>::Type logTotalContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
 {
 	DE_UNREF(log);
 	DE_UNREF(samples);
@@ -1365,7 +1346,7 @@
 }
 
 template <typename SampleType>
-static typename EnableIfNot<void, SampleTypeTraits<SampleType>::HAS_FIRST_RENDER_STATS>::Type logFirstRenderContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
+static typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_FIRST_RENDER_STATS>::Value>::Type logFirstRenderContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
 {
 	DE_UNREF(log);
 	DE_UNREF(samples);
@@ -1373,7 +1354,7 @@
 }
 
 template <typename SampleType>
-static typename EnableIfNot<void, SampleTypeTraits<SampleType>::HAS_SECOND_RENDER_STATS>::Type logSecondRenderContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
+static typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_SECOND_RENDER_STATS>::Value>::Type logSecondRenderContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats)
 {
 	DE_UNREF(log);
 	DE_UNREF(samples);