1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
template < typename T > struct TEmptyStaticArray {} ;
namespace Detail
{
// Not equal, stop and give result:
template<class Type, class CheckedEquals, Type FirstValue, Type SecondValue, class FirstArray, class SecondArray>
struct TCompareStaticArraysSequentially
{
using Equals = CheckedEquals;
};
// Equal, continue:
template<class Type, class CheckedEquals, Type Value, class FirstArray, class SecondArray>
struct TCompareStaticArraysSequentially<Type, CheckedEquals, Value, Value, FirstArray, SecondArray>
{
struct Equals_a : TCompareStaticArraysSequentially<Type, class CheckedEquals::template PushBack<Value>,
FirstArray::PopFront::Front, SecondArray::PopFront::Front,
class FirstArray::PopFront, class SecondArray::PopFront>::Equals {}; // WORKS
// *** disambiguate with typename ***
using Equals_b = typename TCompareStaticArraysSequentially<Type, class CheckedEquals::template PushBack<Value>,
FirstArray::PopFront::Front, SecondArray::PopFront::Front,
class FirstArray::PopFront, class SecondArray::PopFront>::Equals; // DOES NOT WORK
};
// Come to an end of one of the arrays:
template<class Type, class CheckedEquals, Type FirstValue, Type SecondValue, class Array>
struct TCompareStaticArraysSequentially<Type, CheckedEquals, FirstValue, SecondValue, TEmptyStaticArray<Type>, Array>
{
using Equals = CheckedEquals;
};
template<class Type, class CheckedEquals, Type FirstValue, Type SecondValue, class Array>
struct TCompareStaticArraysSequentially<Type, CheckedEquals, FirstValue, SecondValue, Array, TEmptyStaticArray<Type>>
{
using Equals = CheckedEquals;
};
}
template<class Type, class FirstArray, class SecondArray>
struct TCompareStaticArraysSequentially : Detail::TCompareStaticArraysSequentially<Type, TEmptyStaticArray<Type>,
FirstArray::Front, SecondArray::Front, FirstArray, SecondArray>::Equals {};
| |