Re: using vector to encapulate a tree - non const copy constructors
terry wrote:
As Ulrich pointed out, mytree is not yet anything, and there can be no
containment of something that is a nothing.
[...]
I dont understand your comments or those of Ulrich.
The syntax
class T : public: mytemplate<T>
can be perfectly correct C++.
Yes, true. You don't need a complete type in order to use it as template
parameter.
Indeed is widely used and the only way to do certain things.
CRTP, a typical way to implement mixins.
My declaration
class mytree: public T, protected std::vector<mytree>{};
compiles perfectly on all compilers I try, and is, I think, completely
correct C++.
Yes, it might compile, but the standard requires for class vector that the
type it is constructed on be a complete type. This only means that it might
fail on a different compiler, not that it is in itself invalid C++. I
mentioned this as a warning, because it can fail, but what is true is that
it can be made to work in a similar way.
I had hoped my examples near the end of the original posting would be
clear.
Yes, the example was clear, it was just a side issue I noticed.
cheers
Uli
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]