From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: zhang qingshan <steven.zhang54373@gmail.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: questions about cv-qualifier for function and references
Date: Thu, 02 Dec 2010 09:19:00 -0000 [thread overview]
Message-ID: <AANLkTikhVpJK643gstLL0Ew72apBgrsF7LCttn_tXZ+6@mail.gmail.com> (raw)
In-Reply-To: <AANLkTikGdM2YA=0iukdve9Ap-BEHJqfSOsOZEigAyRkY@mail.gmail.com>
On 2 December 2010 04:52, zhang qingshan wrote:
> std(N3126) 8.3.2/1 says that:
>
> Cv-qualified references are ill-formed except when the cv-qualifiers
> are introduced through
> the use of a typedef (7.1.3) or of a template type argument (14.3), in
> which case the cv-qualifiers are ignored.
>
> Why the following code compiled failed on GCC 4.5.0 ?
> template <typename T> void foo (T const &);
> void baz ();
> foo (baz);
you can't call a function at namespace scope
This is the same as:
void foo() { }
foo();
The template and the reference has nothing to do with it.
> while
> template <typename T> void foo (T const &);
> void baz ();
> void Test() {
> foo (baz);
> }
>
> successfully. Really wired.
No, that's completely normal, at function scope you can call another function.
Like:
void foo() { }
void bar() {
foo();
}
> another question is: what is cv-qualifier reference ? Your guys told me that:
> const int &m; is not a cv-qualifier reference. Could you give me an
> example on the cv-qualifier reference ? Thanks.
int i = 0;
int& const cref = i; // error - cannot have cv-qualified reference
prev parent reply other threads:[~2010-12-02 9:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-02 4:52 zhang qingshan
2010-12-02 9:19 ` Jonathan Wakely [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTikhVpJK643gstLL0Ew72apBgrsF7LCttn_tXZ+6@mail.gmail.com \
--to=jwakely.gcc@gmail.com \
--cc=gcc-help@gcc.gnu.org \
--cc=steven.zhang54373@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).