vendredi 2 septembre 2016

Differences between decltype(void()) and decltype(void{})

This is a follow-up of the question: What does the void() in decltype(void()) mean exactly?.


decltype(void()) compiles fine and what the void() means in this case is explained in the above mentioned question (actually in the answer).
On the other side, I noticed that decltype(void{}) doesn't compile.

What's the difference between them (in the context of a decltype at least)?
Why doesn't the second expression compile?


For completeness, it follows a minimal (not-)working example:

int main() {
    // this doesn't compile
    //decltype(void{}) *ptr = nullptr;
    // this compiles fine
    decltype(void()) *ptr = nullptr;
    (void)ptr;
}

Aucun commentaire:

Enregistrer un commentaire