stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Lemings" <Eric.Lemi...@roguewave.com>
Subject Experiment with variadic templates
Date Fri, 06 Jun 2008 22:34:51 GMT
 
Consider the following little program:

------------------------------------------------------------------------

template <class IntType, IntType IntVal>
struct integer {
    typedef IntType value_type;
    static const value_type value = IntVal;
};
 
template <class... TypesT>
struct tuple
{
    tuple ();
    tuple (const tuple&);
    tuple& operator= (const tuple&);
 
};
 
#include <cstddef>
 
template <class... TypesT>
struct tuple_size
    : integer<std::size_t, sizeof... (TypesT)> { };
 
#include <iostream>
 
int main ()
{
    typedef tuple < > tuple0;
    std::cout << tuple_size< tuple0 >::value << std::endl;
 
    typedef tuple < int > tuple1;
    std::cout << tuple_size< tuple1 >::value << std::endl;
 
    return 0;
}

------------------------------------------------------------------------

Compiling with gcc-4.3 using the -std=gnu++0x option (gcc-4.3.1 was
just released BTW), I get the following output:

1
1

The first line should print '0', shouldn't it?  Or no?

Brad.

Mime
View raw message