I have seen a lot of links introducing the variadic templates. But I have never seen any compilable example that demonstrates this approach.
Could someone provide me
This is an example of variadic templates that I put up on my blog: http://thenewcpp.wordpress.com/2011/11/23/variadic-templates-part-1-2/
It compiles. It demonstrates finding the largest type from a group of types.
#include
template
struct find_biggest;
//the biggest of one thing is that one thing
template
struct find_biggest
{
typedef First type;
};
//the biggest of everything in Args and First
template
struct find_biggest
{
typedef typename find_biggest::type next;
typedef typename std::conditional
<
sizeof(First) >= sizeof(next),
First,
next
>::type type;
};