P
Pierre Barbier de Reuille
Hi,
I was wondering if this kind of things are valid as for the C++
standard? It is working with g++, but it may be either a bug (?) or an
"extension" ...
#include <iostream>
template <size_t N>
struct idx
{
typedef const size_t id[ N ];
void set( id i )
{
size_t j;
for( j = 0 ; j < N ; ++j )
{
i_[ j ] = i[ j ];
}
}
size_t i_[ N ];
};
int main()
{
typedef idx<4>::id id;
idx<4> i;
i.set( (id) {2,3,4,5} ); // Initializer used as expression
return 0;
}
Thanks,
Pierre
I was wondering if this kind of things are valid as for the C++
standard? It is working with g++, but it may be either a bug (?) or an
"extension" ...
#include <iostream>
template <size_t N>
struct idx
{
typedef const size_t id[ N ];
void set( id i )
{
size_t j;
for( j = 0 ; j < N ; ++j )
{
i_[ j ] = i[ j ];
}
}
size_t i_[ N ];
};
int main()
{
typedef idx<4>::id id;
idx<4> i;
i.set( (id) {2,3,4,5} ); // Initializer used as expression
return 0;
}
Thanks,
Pierre