Topic: Explicit instantiation and explicit specialization
Author: better_cs_now@yahoo.com ("Dave")
Date: Tue, 9 Dec 2003 15:40:00 +0000 (UTC) Raw View
Hello all,
My understanding is that in the 1998 Standard, a template may not be both
explicitly instantiated and explicitly specialized for the same type. Did
this change in the 2003 Standard and is there anticipated to be any
(further) change in the 0X Standard?
Thanks,
Dave
---
[ 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 ]
Author: francis@robinton.demon.co.uk (Francis Glassborow)
Date: Wed, 10 Dec 2003 02:46:07 +0000 (UTC) Raw View
In article <vtbpl4cn2d2la8@news.supernews.com>, Dave
<better_cs_now@yahoo.com> writes
>Hello all,
>
>My understanding is that in the 1998 Standard, a template may not be both
>explicitly instantiated and explicitly specialized for the same type. Did
>this change in the 2003 Standard and is there anticipated to be any
>(further) change in the 0X Standard?
But how could it be both? A (fully) specialised function template is a
function with a template style signature, an explicitly instantiated
function template is a function with a template signature. You cannot
have both for a single type without breaking the ODR (or having an
entirely pointless specialisation). Or at least that is my current
understanding.
--
Francis Glassborow ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
---
[ 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 ]
Author: AlbertoBarbati@libero.it (Alberto Barbati)
Date: Wed, 10 Dec 2003 02:47:02 +0000 (UTC) Raw View
Dave wrote:
> My understanding is that in the 1998 Standard, a template may not be both
> explicitly instantiated and explicitly specialized for the same type. Did
> this change in the 2003 Standard and is there anticipated to be any
> (further) change in the 0X Standard?
Your understanding is wrong. An explicitly specialized template can be
explicitly instantiated. This possibility is stated in 14.7.2/2 and the
effect of such instantiation is described in 14.7.2/5-7. This has been
true in C++98 and hasn't changed in C++03. I don't know if there's a
change pending in C++0X but it seems very unlikely to me.
Regards,
Alberto Barbati
---
[ 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 ]
Author: dag.henriksson@quidsoft.se ("Dag Henriksson")
Date: Wed, 10 Dec 2003 17:32:50 +0000 (UTC) Raw View
"Alberto Barbati" <AlbertoBarbati@libero.it> skrev i meddelandet
news:4xqBb.178966$e6.6680113@twister2.libero.it...
> Your understanding is wrong. An explicitly specialized template can be
> explicitly instantiated. This possibility is stated in 14.7.2/2 and the
> effect of such instantiation is described in 14.7.2/5-7. This has been
> true in C++98 and hasn't changed in C++03. I don't know if there's a
> change pending in C++0X but it seems very unlikely to me.
I don't find that possibility stated in 14.7.2p2.
14.7.2p5 seems to claim the opposite:
"No program shall /.../, both explicitly instantiate and explicitly
specialize a template ...."
--
Dag Henriksson
---
[ 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 ]
Author: francis@robinton.demon.co.uk (Francis Glassborow)
Date: Wed, 10 Dec 2003 17:33:11 +0000 (UTC) Raw View
In article <4xqBb.178966$e6.6680113@twister2.libero.it>, Alberto Barbati
<AlbertoBarbati@libero.it> writes
>Dave wrote:
>> My understanding is that in the 1998 Standard, a template may not be both
>> explicitly instantiated and explicitly specialized for the same type. Did
>> this change in the 2003 Standard and is there anticipated to be any
>> (further) change in the 0X Standard?
>
>Your understanding is wrong. An explicitly specialized template can be
>explicitly instantiated. This possibility is stated in 14.7.2/2 and the
>effect of such instantiation is described in 14.7.2/5-7. This has been
>true in C++98 and hasn't changed in C++03. I don't know if there's a
>change pending in C++0X but it seems very unlikely to me.
Ah... not quite how I read the OP's question. That explicit
instantiation must take place in the context of the specialisation being
visible. I am also uncertain that the sub-clauses you reference actually
mean what you seem to think they mean. One of the problems is that
during the 90's there was confusion between the term 'specialisation'
and the term 'instantiation' when applied to templates.
--
Francis Glassborow ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
---
[ 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 ]
Author: deepblue57x@yahoo.co.nz (Graeme Prentice)
Date: Wed, 10 Dec 2003 18:23:17 +0000 (UTC) Raw View
On Tue, 9 Dec 2003 15:40:00 +0000 (UTC), better_cs_now@yahoo.com
("Dave") wrote:
>
>Hello all,
>
>My understanding is that in the 1998 Standard, a template may not be both
>explicitly instantiated and explicitly specialized for the same type. Did
>this change in the 2003 Standard and is there anticipated to be any
>(further) change in the 0X Standard?
That's correct - it's currently illegal as per 14.7 para 5. Defect
report 259 proposes to change to the following
For a given template and a given set of template-arguments,
a. an explicit instantiation shall appear at most once in a program,
b. an explicit specialization shall be defined at most once according to
3.2 basic.def.odr in a program, and
c.both an explicit instantiation and a declaration of an explicit
specialization shall not appear in a program unless the explicit
instantiation follows a declaration of the explicit specialization.
This change has "WP" status which means it's years away. I have no idea
why you can't explicitly instantiate and explicitly specialize.
Graeme
---
[ 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 ]