CPP 1.2 NO IDEA Avatar
  1. OMG Issue

CPP12 — Bug on _var references

  • Key: CPP12-11
  • Legacy Issue Number: 4530
  • Status: closed  
  • Source: Triodia Technologies Pty Ltd ( Michi Henning)
  • Summary:

    he spec shows on page 1-13:

    class A_var {
    public:
    // ...
    operator const A_ptr&() const

    { return ptr_; }
    operator A_ptr&() { return ptr_; }

    // ...
    };

    The conversion operator is overloaded for const and non-const.

    Now, two issues here:

    1) It seems that "const A_ptr &" as the return type for the
    first operator is wrong because it really means
    "A * const", not "const A *". So, if anything, I think it
    would have to be written as

    operator const A * &() const

    { return ptr_; }

    2) But why provide a const version of the conversion operator
    at all? Object references are never passed with a const
    qualifier, so why provide this conversion operator? I think
    it could simply be deleted without affecting anything.

    Proposal: Delete the const version of the conversion operator.

    Opinions?

  • Reported: CPP 1.1 — Wed, 22 Aug 2001 04:00 GMT
  • Disposition: Resolved — CPP 1.2
  • Disposition Summary:

    see above

  • Updated: Fri, 6 Mar 2015 20:57 GMT