Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing the void specializations for std::future and std::promise

With regards to the paper which describes removing the void specializations for std::future and std::promise P0241R0. This may be a stupid question but the proposed solution is to remove the void specialization entirely, but then what are people expected to do when they want to instantiate a std::future<void>object?

like image 895
Curious Avatar asked May 19 '17 22:05

Curious


1 Answers

As noted in the reference, this would be possible if void were a regular type.

void get_value() {
    void x;
    return x;
}

This is the way it works in some other languages, so it's not without precedent. In other languages it's called the "unit" type, because it has exactly one possible value. (Other languages also have the "null" type, which has no possible values, so if you try to create one you get an error. It's named "null" but it's unrelated to null pointers.)

like image 96
Dietrich Epp Avatar answered Oct 04 '22 02:10

Dietrich Epp