H
Hendrik Schober
Hi,
I am trying to test a command line parser. So I came up
with this (simplified):
struct test {
int argc;
const char** argv;
template< int N >
test(const char* (&a)[N])
: argc(N-1)
, argv(a)
{
}
};
const char* a1[] = { "1", "22", "333" };
const char* a2[] = { "1", "22", "333" };
const test v1[] = { test(a1)
, test(a2) };
const test v2[] = { test( { "1", "22", "333" } )
, test( { "1", "22", "333" } ) };
template<int N>
void testParser(const test (&arr)[N]);
int main()
{
testParser(v1);
testParser(v2);
return 0;
}
Both VC7.1 and Comeau choke on 'v2'. (Comeau says
"expected an expression", VC issues a "missing ')'
before '{'" -- not very helpful.)
Obviously I can't initialize the struct with an
array literal. I can, however, initialize it with
an array object. The reason behind this escapes
me.
What's more important, I would really like to have
my test cases in one line and not split into two
objects.
Ideas anyone?
Schobi
--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org
"Coming back to where you started is not the same as never leaving"
Terry Pratchett
I am trying to test a command line parser. So I came up
with this (simplified):
struct test {
int argc;
const char** argv;
template< int N >
test(const char* (&a)[N])
: argc(N-1)
, argv(a)
{
}
};
const char* a1[] = { "1", "22", "333" };
const char* a2[] = { "1", "22", "333" };
const test v1[] = { test(a1)
, test(a2) };
const test v2[] = { test( { "1", "22", "333" } )
, test( { "1", "22", "333" } ) };
template<int N>
void testParser(const test (&arr)[N]);
int main()
{
testParser(v1);
testParser(v2);
return 0;
}
Both VC7.1 and Comeau choke on 'v2'. (Comeau says
"expected an expression", VC issues a "missing ')'
before '{'" -- not very helpful.)
Obviously I can't initialize the struct with an
array literal. I can, however, initialize it with
an array object. The reason behind this escapes
me.
What's more important, I would really like to have
my test cases in one line and not split into two
objects.
Ideas anyone?
Schobi
--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org
"Coming back to where you started is not the same as never leaving"
Terry Pratchett