Indiana Unversity logo[ConceptGCC]

ConceptGCC :

DefaultConstructible concept satisfied by an incomplete class?

From: nielsprogramming_at_[hidden]
Date: 2007-07-01 17:23:20


Is it possible to have a concept satisfied by an incomplete class???

The issue was raised this weekend at comp.std.c++:
Re: C++0x static_assert(0, "") within a non-instantiated template okay?

I wrote to comp.std.c++, yesterday (June 30):
> I guess that by definition sizeof(T) > 0 is true for every
> DefaultConstructible type T. So a C++0x compiler would be allowed
> to diagnose the following template definition, even without being
> instantiated:
>
> #include <concepts>
>
> template<std::DefaultConstructible T>
> void TemplateFunc(void) {
> static_assert(sizeof(T)==0, "Ill-formed!");
> }

Alberto Ganesh Barbati replied today (July 1st):
> Hmm... I haven't fully grasped all the details of concepts, so I may be
> wrong, but can't you declare a type to be DefaultConstructible before
> providing a definition for such type? In that case you would have a
> DefaultConstructible type which is still incomplete [...]

I can't really imagine how an incomplete class would satisfy a concept,
but I'm not yet an expert on concepts either... So your help is
appreciated! :-)

-- 
Niels Dekker
http://www.xs4all.nl/~nd/dekkerware
Scientific programmer at LKEB, Leiden University Medical Center