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;
+};
+
//! 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)
+{
+ DE_ASSERT(inBounds(offset, 0, Size));
+ return array[offset];
+}
+
+//! Get an element of an array with a compile-time constant size.
template <int Size, typename Elem>
-const Elem& getSizedArrayElement(const Elem (&array)[Size], int offset)
+const Elem& getArrayElement (const Elem (&array)[Size], int offset)
{
DE_ASSERT(inBounds(offset, 0, Size));
return array[offset];
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
};
- return de::getSizedArrayElement(cubeFaces, ndx);
+ return de::getSizedArrayElement<6>(cubeFaces, ndx);
}
deUint32 getFormatForInternalFormat (deUint32 format)
{
const Precision precision = Precision(precNdx);
const string precName (glu::getPrecisionName(precision));
- const FloatFormat& fmt = *de::getSizedArrayElement(ctx.formats, precNdx);
- const FloatFormat& highpFmt = *de::getSizedArrayElement(ctx.formats,
- glu::PRECISION_HIGHP);
+ const FloatFormat& fmt = *de::getSizedArrayElement<glu::PRECISION_LAST>(ctx.formats, precNdx);
+ const FloatFormat& highpFmt = *de::getSizedArrayElement<glu::PRECISION_LAST>(ctx.formats,
+ glu::PRECISION_HIGHP);
for (size_t shaderNdx = 0; shaderNdx < ctx.shaderTypes.size(); ++shaderNdx)
{