const void ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas Lenz

    #1

    const void ?

    Hi everybody,

    does it make sense to declare a function with a return type of const void
    instead of void? I found (by accident) that the compiler makes a difference
    between these two, but I don't understand why.

    Thanks,
    Thomas
  • James Kanze

    #2
    Re: const void ?

    On Oct 25, 8:58 am, Thomas Lenz <len...@gmx.dew rote:
    does it make sense to declare a function with a return type of
    const void instead of void?
    Not really. Top level const doesn't apply to rvalues of
    non-class type. Something like that could reasonably occur,
    however, as the result of instantiating a template.
    I found (by accident) that the compiler makes a difference
    between these two, but I don't understand why.
    Error in the compiler? According to my reading of the standard,
    void and void const are the same type when used as an rvalue.
    (I think the standard can be interpreted in two different ways
    here: that the compiler should ignore the cv-qualifiers in this
    case, or that it shouldn't allow them. Every compiler I've
    tried, however, allows them and doesn't ignore them.)

    --
    James Kanze (GABI Software) email:james.kan ze@gmail.com
    Conseils en informatique orientée objet/
    Beratung in objektorientier ter Datenverarbeitu ng
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

    Comment

    Working...