This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Concept-check bug ?
Jonathan Wakely <cow@compsoc.man.ac.uk> writes:
| On Fri, Jun 17, 2005 at 03:12:40PM +0300, Peter Dimov wrote:
|
| > Jonathan Wakely wrote:
| > >Hi y'all,
| > >
| > > #define _GLIBCXX_CONCEPT_CHECKS
| > > #include <vector>
| > >
| > > struct A {
| > > std::vector<A> v;
| > > };
| > >
| > >This produces concept-check errors because A is incomplete at the
| > >point of declaring v.
| > >
| > >Is this code really illegal, or just a flaw in the concept-checks ?
| >
| > It's illegal (17.4.3.6/2 last bullet), but useful.
|
| Thanks, Peter (I should have known that).
|
| Presumably the truly legal way to do it is with a (smart) pointer to the
Probably "legal", but surely overkill and obfuscatory.
Do you really believe that
template<class T>
struct Vector {
T* data;
int size;
// ...
};
struct A {
Vector<A> v;
};
shall be expressed as:
| struct A {
| std::tr1::shared_ptr<std::vector<A> > v;
|
| A() : v(new std::vector<A>) { }
| };
?
Ugh.
-- Gaby