#include <iostream>
#include <type_traits>
#include <vector>
#include <string>
#include <functional>
#include <map>
#include <algorithm>
#include <sstream>
#include <set>
#include <unordered_map>
// check if type of static array
template <class T>
struct ABIStaticArray : std::false_type //#1
{
ABIStaticArray()
{
std::cout <<"#1"<<std::endl;
}
};
// stringN type => bytesN
template <std::size_t N>
struct ABIStaticArray<std::array<char, N>> : std::false_type //#2
{
ABIStaticArray()
{
std::cout <<"#2"<<std::endl;
}
};
// a fixed-length array of N elements of type T.
template <class T, std::size_t N>
struct ABIStaticArray<std::array<T, N>> : std::true_type //#3
{
ABIStaticArray()
{
std::cout <<"#3"<<std::endl;
}
};
// fixed length of type, default 1 except static array type
template <class T, class Enable = void> //#4
struct Length
{
enum
{
value = 1
};
Length()
{
std::cout <<"#4"<<std::endl;
}
};
// length of static array type
template <class T>
struct Length<T, typename std::enable_if<ABIStaticArray<T>::value>::type> //#5
{
enum
{
value = std::tuple_size<T>::value * Length<typename std::tuple_element<0, T>::type>::value
};
Length()
{
std::cout <<"specialization #5"<<std::endl;
}
};
int main()
{
Length<std::array<int, 5>> v;
}