$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: scleary_at_[hidden]
Date: 1999-12-16 16:59:06
Some stuff on cv-qualifications in template arguments:
>
> Builder 4 accepts these [cv-qualified referneces] also, but: look at
8.3.2 - these seem to be
> specifically disallowed - they can only be introduced inadvertently via a
> typedef or in template code - and when they are the cv-modifiers must be
> discarded.  This makes sense a cv-qualified reference is an
> oxymoron if ever I saw one :-)
>
typedef int& A;
const A aref = 3;
does not make any sense.  However,
template <typename T>
struct remove_reference<T const &> { typedef T const type; };
does.  (Builder allows "T & const" to mean the same as "T const &", though
this is syntactically invalid -- ANSI 7 & 8 gives the grammar for
declarations.)  We are not using a cv-qualified reference.  What we are
doing is using a reference to a cv-qualified T.  This is perfectly legal
because you can follow the Standard through a(n incredibly complicated)
series of procedures, ending at function template argument deduction in ANSI
14.8.2.1p2 "If P [the function template parameter type] is not a reference
type. . .If P is a cv-qualified type, the top level cv-qualifiers of P's
type are ignored for type deduction.  If P is a reference type, the type
referred to by P is used for type deduction."  That is, top-level
cv-qualifiers are stripped for every types except references (or another
(read: better, IMHO) way to look at it is that references don't _have_ any
top-level cv-qualifiers).
Referring to John's code posted earlier this week:
  . remove_reference does not need the cv-qualified versions.  They are
unnecessary because "template <typename T> struct remove_reference<T&>
 typedef T type; };" will match "cv-list R" with "T".  Note that the
resulting type maintains its cv-qualification; it only loses its reference.
  . is_pointer cannot have top-level cv-qualifications.  In my earlier
posting I pointed out ANSI 14.1p5.  It can have specializations for "cv-list
T *", but that would not get us anything; it's the same result as the
references above.
  . For the same reason, the POD helpers don't have to strip the
cv-qualifications.
        -Steve
P.S.  I'm writing a short web page on Matching and Selection of Class
Template Partial and Explicit Specializations, because I find it to be a
very confusing subject, and the Standard jumps around a _lot_ explaining it!
It's mostly just quotes from the Standard right now, but I plan to add
English explanations :) (maybe enough to replace the quotes) and some
examples.  My question is: can anyone put this on the Web for me?  I don't
have "real" Web access. . .