By "min" type, I mean the type compared less than all according to a compile time function, eg sizeof
I have a draft implementation, will present it first and refer to the two problems I'm facing:
#include <iostream>
#include <typeinfo>
#include <type_traits>
using namespace std;
// Unspecialized version
template<typename...Ts>
struct Tmin
{
using type = void;
};
template<typename T>
struct Tmin<T>
{
using type = T;
};
template<typename T1, typename T2, typename...Ts>
struct Tmin<T1, T2, Ts...>
{
using type = typename std::conditional<sizeof(T1) < sizeof(T2),
typename Tmin<T1, Ts...>::type, typename Tmin<T2, Ts...>::type
>::type;
};
int main()
{
cout << typeid(Tmin<float, int, double>::type).name() << endl;
return 0;
}
This does not work in VS2013 (emits
fatal error C1075
). Am I using any non standard facilities or is there a more conforming way to write the above ?Say I want to use means other than
sizeof
to compare types. Is there a consice way / good design to be able to pass metafunctions as comparators and still maintain a default behaviour (where non specified otherwise that is) that would usesizeof
?