freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch: Expanding Supported Explicit Instantiations


From: Jeffrey Oldham
Subject: Patch: Expanding Supported Explicit Instantiations
Date: Fri, 25 May 2001 10:44:33 -0700
User-agent: Mutt/1.2.5i

Dave Nystrom desired to explicitly instantiate this program:

    #include "Pooma/NewFields.h"
  
    #define T1 NoGeometry<(int)3>
    #define T2 int
    #define T3 CompressibleBrick
    #define T4 Interval<(int)3>
    template View1<Field<T1,T2,T3>,T4>::sv;

I do not know the correct syntax for explicitly instantiating View1's
const static bool `sv' if this is even legal.  The attached patch
permits instantiating

    #include "Pooma/NewFields.h"

    #define T1 NoGeometry<(int)3>
    #define T2 int
    #define T3 CompressibleBrick
    #define T4 Interval<(int)3>
    template class View1<Field<T1,T2,T3>,T4>;

It also permits

    template View0<Array<2,T2,T3> >;

without first explicitly instantiating Array<2,T2,T3>;

The main idea is to break mutually recursive class definitions by
defining alternative `View' classes that contain all the type
definitions of their corresponding `View' classes but omit the member
functions.  These alternative classes provide the return type for
non-templated member functions of Array and Field classes.  These
member functions' bodies still use the View classes.  Since the
alternative classes' definitions are the same as for the View classes,
this trickery works.  If a View class's code changes, the
corresponding alternative class's code must also be changed.  This
might lead to future maintenance problems.

Stephen Smith provided the insight for the patch so he deserves all
positive credit.  Send all criticisms to Jeffrey.

2001-05-25  Jeffrey D. Oldham <address@hidden>
        * Array/Array.h (View0): Modify initial comment to indicate
        changes should also be made to AltView0.
        (AltView0): New class to avoid explicit instantiation problems.
        (ComponentView): Modify initial comment to indicate class should
        not be explicitly instantiated.
        (Array::read()): Change return type to AltView0.
        (Array::operator()()): Likewise.

        * NewField/Field.h (View1Implementation): Modify initial comment
        to indicate changes should also be made to AltView1Implementation.
        (AltView1Implementation): New class to avoid explicit
        instantiation problems.
        (View1): Modify initial comment to indicate changes should also be
        made to AltView1.
        (AltView1): New class to avoid explicit instantiation problems.
        (Field::read()): Change return type to AltView1.
        (Field::readAll()): Likewise.
        (Field::read(s1)): Likewise.
        (Field::operator()()): Likewise.
        (Field::all()): Likewise.
        (Field::operator()(s1)): Likewise.

Tested on       sequential Linux using gcc 3.0
Approved by     Scott Haney

Thanks,
Jeffrey D. Oldham
address@hidden

Attachment: explicit.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]