[pooma-dev] question for language gurus

Julian Cummings cummings at cacr.caltech.edu
Wed Apr 18 21:25:03 UTC 2001


Jeffrey Oldham wrote:

> On Tue, Apr 17, 2001 at 07:34:05PM -0700, Julian Cummings wrote:
> > Is the code at line 1421 of DynamicLayout.h legit?
> > This is a templated constructor for DynamicLayoutViewData
> > that takes a DynamicLayoutView object as its first argument.
> > The aCC compiler complains about calling member functions
> > of the DynamicLayoutView argument because the class has
> > not yet been defined (it is defined further down in the file)
> > and is thus incomplete.  The aCC compiler swallows the code
> > if I move this constructor definition outside the class definition
> > and below the definition of class DynamicLayoutView.
> >
> > The point of instantiation for this templated constructor clearly
> > happens later in some other file that is including DynamicLayout.h.
> > But since DynamicLayoutView is not a templated type, it is not
> > dependent on the template parameter for the constructor.  So perhaps
> > this is a legitimate error and the code must be moved out of line and
> > after the definition of DynamicLayoutView.  Comments?
>
> I prefer to make it compile without complaint.
>
> Thanks,
> Jeffrey D. Oldham
> oldham at codesourcery.com

Well, OK.  But I don't know if any other compilers besides aCC are
annoyed by this.  I was really asking whether the code structure here
is legal or not.  BTW, I found another case of this sort of thing in
TensorElements.h.  There is a class Unwritable that is forward declared,
and then defined later on.  Before the definition of Unwritable, there
is a class template defined that uses the Unwritable constructor to
create and return an Unwritable object.  aCC complains unless the
definition of Unwritable is moved ahead of this class template definition.

Even if it is technically legal, would it be OK with folks to do this
amount of modest code reordering, so that a class definition is seen
before an object of the class is used in a class or function template?

Julian C.


--
Dr. Julian C. Cummings                       E-mail: cummings at cacr.caltech.edu
California Institute of Technology           Phone:  626-395-2543
1200 E. California Blvd., Mail Code 158-79   Fax:    626-584-5917
Pasadena, CA 91125






More information about the pooma-dev mailing list