dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #02230
Re: Parameter.h
On Sat, Mar 25, 2006 at 12:08:52AM +0100, Garth N. Wells wrote:
> On Fri, 2006-03-24 at 16:58 -0600, Anders Logg wrote:
> > Do you mean the following?
> >
> > Iterator& operator++();
> > Iterator& operator--();
> >
> > Operators ++ and -- return a reference to an iterator so you can do
> > things like
> >
> > Iterator it;
> > (++it)->foo();
> >
> > I think this is fairly standard.
> >
> > But I agree that the PArray class probably looks funny in many
> > ways... I have wanted to remove it for a long time, but the Mesh class
> > relies heavily on it so it would require a bit of work. (And since
> > Sieve should be pretty close, it may be unecessary to put in that
> > work.)
> >
> > I can't figure out why you get problems with the compilation.
> >
> > Does it help if you move the definition of the operators in question
> > from below (line 443) and just throw them directly in to the class
> > definition?
> >
>
> Yes, then it works fine.
>
> I found a lot of information on how to define functions outside of a
> template, but not for classes which are nested inside a template.
It's starting to come back to me now... I remember that I had trouble
with declaring the nested functions outside of the template and
finally found a solution that worked for gcc, but obviously not for
all compilers.
> Given that PAraay.h should disappear soon, I'll move the functions into
> the class.
Great.
/Anders
> Garth
>
> > So you would have just
> >
> > Iterator& operator++()
> > {
> > if ( _index == (size - 1) )
> > at_end = true;
> > else {
> > at_end = false;
> > _index++;
> > }
> >
> > element = array + _index;
> >
> > return *this;
> > }
> >
> > and similarly for operator-- in the definition of the class Iterator
> > instead of all the other crap with typename etc below?
> >
> > The reason it looks like this is that I wanted to move the
> > implementation to somewhere else (like to a .cpp file but I can't do
> > that with a template). You can do this by figuring out the correct
> > (but hard to get right) syntax, but it's easier to get through the
> > compiler if you just stick the code in the class definition.
> >
> > /Anders
> >
> >
> > On Fri, Mar 24, 2006 at 11:05:33PM +0100, Garth N. Wells wrote:
> > > On Fri, 2006-03-24 at 14:20 -0600, Anders Logg wrote:
> > > > Hmm...
> > > >
> > > > I don't like these errors. I don't remember why I put in the
> > > > "typename" at all, but probably to get around some compiler errors
> > > > that gcc gave me previously. What happens if you just remove the word
> > > > "typename"?
> > > >
> > > still doesn't work. The class Iterator looks funny to me. The class is
> > > called Iterator, and has member functions which return the address of an
> > > Iterator.
> > >
> > > Garth
> > >
> > > > PArray.h will be removed as soon as we replace the mesh backend with
> > > > Sieve (whenever that may be, we're still waiting for Sieve but it
> > > > should come soon).
> > > >
> > > > /Anders
> > > >
> > > >
> > > > On Fri, Mar 24, 2006 at 06:56:35PM +0100, Garth N. Wells wrote:
> > > > > That works. I did that but wasn't sure if it had any consequences.
> > > > >
> > > > > The only remaining problem I have that I haven't figured out yet is in
> > > > > PArray.h. The error messages are below.
> > > > >
> > > > > I picked up a whole bunch of other small errors, but it might take me a
> > > > > few days to get them all checked in.
> > > > >
> > > > > Garth
> > > > >
> > > > > ./../../src/kernel/common/dolfin/PArray.h(445): error: overloaded
> > > > > function "dolfin::PArray<T>::Iterator::Iterator" is not a type name
> > > > > template <class T> typename PArray<T>::Iterator::Iterator&
> > > > > ^
> > > > >
> > > > > ../../../src/kernel/common/dolfin/PArray.h(446): error: declaration is
> > > > > incompatible with "dolfin::PArray<T>::Iterator
> > > > > &dolfin::PArray<T>::Iterator::operator++()" (declared at line 147)
> > > > > PArray<T>::Iterator::operator++()
> > > > > ^
> > > > >
> > > > > ../../../src/kernel/common/dolfin/PArray.h(460): error: overloaded
> > > > > function "dolfin::PArray<T>::Iterator::Iterator" is not a type name
> > > > > template <class T> typename PArray<T>::Iterator::Iterator&
> > > > > ^
> > > > >
> > > > > ../../../src/kernel/common/dolfin/PArray.h(461): error: declaration is
> > > > > incompatible with "dolfin::PArray<T>::Iterator
> > > > > &dolfin::PArray<T>::Iterator::operator--()" (declared at line 149)
> > > > > PArray<T>::Iterator::operator--()
> > > > > ^
> > > > >
> > > > >
> > > > > On Fri, 2006-03-24 at 11:03 -0600, Anders Logg wrote:
> > > > > > Does it work if you remove the dolfin:: in Parameter.h? I don't know
> > > > > > why it's there. I just pushed a changeset where this is removed. Check
> > > > > > if that works.
> > > > > >
> > > > > > /Anders
> > > > > >
> > > > > > On Fri, Mar 24, 2006 at 05:58:18PM +0100, Garth N. Wells wrote:
> > > > > > > Any ideas what's wrong here in Parameter.h? I'm testing the Intel C++
> > > > > > > compiler.
> > > > > > >
> > > > > > > Garth
> > > > > > >
> > > > > > > ../../../src/kernel/parameter/dolfin/Parameter.h(89): error: no instance
> > > > > > > of overloaded function "dolfin::operator<<" matches the specified type
> > > > > > > friend LogStream& dolfin::operator<<(LogStream& stream, const
> > > > > > > Parameter& parameter);
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > DOLFIN-dev mailing list
> > > > > > > DOLFIN-dev@xxxxxxxxxx
> > > > > > > http://www.fenics.org/cgi-bin/mailman/listinfo/dolfin-dev
> > > > > > >
> > > > >
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > DOLFIN-dev mailing list
> > > > > DOLFIN-dev@xxxxxxxxxx
> > > > > http://www.fenics.org/cgi-bin/mailman/listinfo/dolfin-dev
> > > > >
> > >
> > >
> > >
> > > _______________________________________________
> > > DOLFIN-dev mailing list
> > > DOLFIN-dev@xxxxxxxxxx
> > > http://www.fenics.org/cgi-bin/mailman/listinfo/dolfin-dev
> > >
>
>
>
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/cgi-bin/mailman/listinfo/dolfin-dev
>
--
Anders Logg
Research Assistant Professor
Toyota Technological Institute at Chicago
http://www.tti-c.org/logg/
References