Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
reference collapsing and cv-qualifiers
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Russell Yanofsky  
View profile  
 More options Sep 24 2005, 4:46 pm
Newsgroups: comp.std.c++
From: "Russell Yanofsky" <russell.yanof...@us.army.mil>
Date: Sat, 24 Sep 2005 14:46:55 CST
Local: Sat, Sep 24 2005 4:46 pm
Subject: reference collapsing and cv-qualifiers
The proposed "reference collapsing" solution to CWG Defect 106 [1]
treats cv-qualifiers on reference types differently than other parts of
the language. Consider the following function declaration:

  typedef int &int_ref;
  void foo(int_ref const); // equivalent to void foo(int &);

The current C++ standard in 8.3.2p1 requires that the const qualifier
on the int_ref type be ignored. Now consider a similar declaration
which would be allowed under DR106:

  typedef int &int_ref;
  void foo(int_ref const &); // equivalent to void foo(int const &);

In this case, DR106 requires that the const qualifier be applied. So,
in one case, the const qualifier is applied, in the other it isn't,
even though the two declarations are identical except for a redundant &
operator.

I don't see why it needs to be this way. It'd be better if DR-106 were
either scaled back so cv-qualifiers on references were consistently
ignored throughout the language, or broadened so they could be
consistently applied.

Also, this inconsistency can make implementing DR-106 a PITA for
compiler writers, because you can longer interpret type expressions
"int_ref const &" straight from left to right. You used to be able know
what the "const" on "int_ref const" was supposed to do as soon as you
encountered it, whereas now you have to peek ahead for "&" operators to
know whether or not to apply it. At least that was my experience trying
to implement DR106 for GCC. I wonder if the author/authors of this
proposal were aware of 8.3.2p1 and how it conflicts (conceptually) with
the behavior they specify for reference collapsing.

- Russ

[1] http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#106

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-...@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Russell Yanofsky  
View profile  
 More options Sep 24 2005, 4:46 pm
Newsgroups: comp.std.c++
From: "Russell Yanofsky" <russell.yanof...@us.army.mil>
Date: Sat, 24 Sep 2005 14:46:55 CST
Local: Sat, Sep 24 2005 4:46 pm
Subject: reference collapsing and cv-qualifiers
The proposed "reference collapsing" solution to CWG Defect 106 [1]
treats cv-qualifiers on reference types differently than other parts of
the language. Consider the following function declaration:

  typedef int &int_ref;
  void foo(int_ref const); // equivalent to void foo(int &);

The current C++ standard in 8.3.2p1 requires that the const qualifier
on the int_ref type be ignored. Now consider a similar declaration
which would be allowed under DR106:

  typedef int &int_ref;
  void foo(int_ref const &); // equivalent to void foo(int const &);

In this case, DR106 requires that the const qualifier be applied. So,
in one case, the const qualifier is applied, in the other it isn't,
even though the two declarations are identical except for a redundant &
operator.

I don't see why it needs to be this way. It'd be better if DR-106 were
either scaled back so cv-qualifiers on references were consistently
ignored throughout the language, or broadened so they could be
consistently applied.

Also, this inconsistency can make implementing DR-106 a PITA for
compiler writers, because you can longer interpret type expressions
"int_ref const &" straight from left to right. You used to be able know
what the "const" on "int_ref const" was supposed to do as soon as you
encountered it, whereas now you have to peek ahead for "&" operators to
know whether or not to apply it. At least that was my experience trying
to implement DR106 for GCC. I wonder if the author/authors of this
proposal were aware of 8.3.2p1 and how it conflicts (conceptually) with
the behavior they specify for reference collapsing.

- Russ

[1] http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#106

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-...@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google