From 786125308745239641
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,d53338cd62537f87
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2002-04-17 17:16:01 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!kibo.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: "Giovanni Bajo" <giovannibajo@REMOVEliberoTHIS.it>
Newsgroups: comp.std.c++
Subject: Re: What does the standard say about Loki's ConversionHelper
Date: Thu, 18 Apr 2002 00:15:14 GMT
Organization: [Infostrada]
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <rKmv8.50925$SR5.1307019@twister1.libero.it>
References: <3cbdd850.75707781@news.mar.lmco.com>
X-Trace: mail2news.demon.co.uk 1019088919 mail2news:14740 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4807.1700
X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
NNTP-Posting-Date: Thu, 18 Apr 2002 00:32:55 MET DST
Lines: 50
Xref: archiver1.google.com comp.std.c++:10679


"Mark Heaps" <heapsma@lmtas.lmco.com> ha scritto nel messaggio
news:3cbdd850.75707781@news.mar.lmco.com...

> My compiler rejects the following snippet from the Loki library:

> [...]

>   enum { exists = sizeof(H::Test(H::MakeT())) == sizeof(H::Small) };

> [...]

> The last of several exchanges with the compiler vendor, resulted in
> this analysis:

>  - in the example given, the class 'Conversion' is referring to the
> class 'Private::ConversionHelper' which hasn't been instantiated. When
> a member of the latter class is looked up, none of its internal
> information is known, so the expressions in the sizeof operator are
> viewed as not having complete types.

>[...]

> So my questions are:
> What paragraphs of the standard support (or refute) that analysis?
> Is the code legal or illegal?

The code is legal.

14.7.1/1 [temp.inst]: "Unless a class template specialization has been
explicitly instanciated or explicitly specialized, the class template
specialization is implicitly instanciated when the specialization is
referenced in a context that requires a completely-defined object type or
when the completeness of the class type affects the semantics of the
problem".

The context above clearly requires a "completly-defined object type", so the
argument of the vendor, specifically "the expressions [...] are viewed as
not having complete types" does not apply: they do not have complete type
because the template has not been instanciated, but 14.7.1 mandates an
implicitly instanciation whenever a complete type is needed.

Giovanni Bajo

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



