Boost logo

Boost :

From: scleary_at_[hidden]
Date: 1999-12-20 09:09:13


> | And I have to conclude that it is NOT legal, for the following reason:
> |
> | ISO :) 14.1p5 ". . .The top-level cv-qualifiers on the
template-parameter are
> | ignored when determining its type."
>
> No, I don't think so. You are confusing 'template-parameter' with
> 'template-argument'. The paragraph you're quoting applies to
> non-type template-parameter as evidenced by the full context. For the
> sake of clarity, here is the context:
>
> 14.1/4
>
> A non-type template-parameter shall have one of the following
> (optionally cv-qualified) types:
> --- integral or enumeration type,
> --- pointer to object or pointer to function,
> --- reference to object or reference to function,
> --- pointer to member.
>
> The Standards goes on saying:
>
> 14.1/5
>
> [Note: other types are disallowed either explicitly below or
> implicitly by the rules governing the form of template-arguments
> (14.3). ] The top-level cv-qualifiers of the template-parameter are
> ignored when determining its type.
>
> Note that only a non-type template-parameter may have a type.
> [ Types aren't (yet) first class objects in C++. ]
>
>
> | The above code will result in ambiguity -- the compiler _should_ choke
on
> | whether to use "X<int>" or "X<const int>".
>
> Did yours?
>
> The paragraph you're quoting doesn't apply. 'int' and 'const int'
> are distinct template-arguments; furthermore X<int> and <const int>
> are distinct class types.
>
> | Also, this means "numeric_limits<const int>::is_specialized" is _true_.
>
> No, 'const int' isn't a *fundamnetal* type.
>

Yes, I incorrectly quoted the Standard; as you pointed out, my quotation
refers only to non-type template parameters. However, I still don't think
that

template <class T> struct X { };
template <> struct X<int> { };
template <> struct X<const int> { };
X<const int> bob;

will work. In [Deducing template arguments from a type] (14.8.2.4), para 9
gives us a list of matchable forms, one of which is "cv-list T". I take
this to mean that "X<const int>" will match both specializations, and
neither is more specialized than the other, resulting in ambiguity. Is this
correct?

        -Steve


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