cv-qualified rvalues

Discussion in 'C++' started by Steven T. Hatton, Dec 14, 2006.

  1. This footnote appears in the section of the Standard specifying lvalue to
    rvalue conversion.

    (footnote 49)"In C++ class rvalues can have cv-qualified types (because they
    are objects). This differs from ISO C, in which non-lvalues never have
    cv-qualified types."

    I believe I understand the basics of what it's saying. I could have some
    class-type object on the right side of an assignment operator. I'm not
    completely sure what the significance of it being cv-qualified is. Is this
    related to the kind of thing that happens with std::auto_ptr<> when it
    changes state if its owned object is assigned away?
    --
    NOUN:1. Money or property bequeathed to another by will. 2. Something handed
    down from an ancestor or a predecessor or from the past: a legacy of
    religious freedom. ETYMOLOGY: MidE legacie, office of a deputy, from OF,
    from ML legatia, from L legare, to depute, bequeath. www.bartleby.com/61/
     
    Steven T. Hatton, Dec 14, 2006
    #1
    1. Advertising

  2. Steven T. Hatton wrote:
    > This footnote appears in the section of the Standard specifying
    > lvalue to rvalue conversion.
    >
    > (footnote 49)"In C++ class rvalues can have cv-qualified types
    > (because they are objects). This differs from ISO C, in which
    > non-lvalues never have cv-qualified types."
    >
    > I believe I understand the basics of what it's saying. I could have
    > some class-type object on the right side of an assignment operator.
    > I'm not completely sure what the significance of it being
    > cv-qualified is. Is this related to the kind of thing that happens
    > with std::auto_ptr<> when it changes state if its owned object is
    > assigned away?


    #include <iostream>
    struct A {
    void foo() const { std::cout << "A::foo() const\n"; }
    void foo() { std::cout << "A::foo()\n"; }
    };

    A bar() { return A(); }
    A const cbar() { return A(); }

    int main() {
    bar().foo(); // calls foo
    cbar().foo(); // calls foo const
    }

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Dec 14, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steven T. Hatton
    Replies:
    11
    Views:
    679
    Alf P. Steinbach
    Apr 20, 2004
  2. Replies:
    6
    Views:
    517
    Rolf Magnus
    Jun 8, 2005
  3. Lvalues and Rvalues

    , Oct 14, 2006, in forum: C Programming
    Replies:
    3
    Views:
    353
    SM Ryan
    Oct 14, 2006
  4. Szabolcs Borsanyi

    Pointer to qualified poitner to qualified object

    Szabolcs Borsanyi, May 30, 2008, in forum: C Programming
    Replies:
    13
    Views:
    562
    Keith Thompson
    Jun 8, 2008
  5. Nicklas Karlsson

    lvalues and rvalues

    Nicklas Karlsson, Apr 6, 2010, in forum: C Programming
    Replies:
    127
    Views:
    2,619
    Tim Rentsch
    May 5, 2010
Loading...

Share This Page