dimanche 1 septembre 2019

Why are true, false and nullptr prvalues?

As far as I'm aware nullptr is an instance of some class, something like this:

const
class {
public:
    template<class T> // convertible to any type
    operator T*() const // of null non-member
    { return 0; } // pointer...
    template<class C, class T> // or any type of null
    operator T C::*() const // member pointer...
    { return 0; }
private:
    void operator&() const; // whose address can't be taken
} nullptr = {};

Is the fact that it is a prvalue a dirty hack violating the language's type system?

Aucun commentaire:

Enregistrer un commentaire