Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 1999-12-16 20:58:49


scleary_at_[hidden] wrote on 12/16/99 10:20 AM
>I've been doing some research into the Standard to see if the following is
>legal:
>
>template <class T> struct X { };
>template <> struct X<int> { };
>template <> struct X<const int> { };
>X<const int> bob;
>
>And I have to conclude that it is NOT legal, for the following reason:
>
>ANSI 14.1p5 ". . .The top-level cv-qualifiers on the template-parameter are
>ignored when determining its type."
>
>The above code will result in ambiguity -- the compiler _should_ choke on
>whether to use "X<int>" or "X<const int>".
>
>Also, this means "numeric_limits<const int>::is_specialized" is _true_.

I was (and still am) confused on the same issue (and on the same quote
from the standard) about a week ago. I first asked our resident language
lawyer if we could specialize on cv qualifed types: yes. Then I checked
with the library working group of the C++ committee with the question:
What is the value of numeric_limits<const int>::is_specialized? Answer:
false.

Perhaps you should post this issue to comp.std.c++. I would be most
interested in following that thread. There are parts of chapter 14 (and
this is one of them) that remain a complete mystery to me.

-Howard


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk