[Insight-developers] compile error

Brad King brad.king@kitware.com
Wed, 11 Apr 2001 15:20:19 -0400 (EDT)


> I'd like to be able to do:
> 
> itk::Index<3> myIndex = 1,2,3;
> itk::Array<long,3> myArray = 1,2,3;
> 
> I can now do:
> 
> itk::Index<3> myIndex;
> myIndex = 1,2,3;
> 
> itk::Array<long,3> myArray;
> myArray = 1,2,3;

To my knowledge, this is not possible because of parsing issues.  A comma
is parsed differently in a declaration than in an expression:

// Declarations with initalizations are parsed like this:
(itk::Index<3> (myIndex = 1), (2), (3));
// error: "2" is not a valid variable identifier.
// error: "3" is not a valid variable identifier.

// Expressions are parsed like this:
(((myIndex = 1),2),3);

I'll think about some alternative approaches, but it is not promising.

-Brad