Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does 'auto t = new decltype(nullptr)' do? [duplicate]

Under gcc (and possibly other compilers) it is possible to write:

auto t = new decltype(nullptr);

I'm not sure what this does. Does that allocate memory for an object of type nullptr_t?

My question is not about the type of nullptr that is nullptr_t , my question is how does new nullptr_t() make sense ?

like image 203
Hassen Dhia Avatar asked Oct 22 '25 04:10

Hassen Dhia


1 Answers

Does that allocate memory for an object of type nullptr_t?

Yes.

my question is how does new nullptr_t() make sense ?

From a syntactic point of view, there is nothing wrong with that.

From a semantic point of view, I can't see any sensible use case for it. All instances of nullptr_t are essentially the same from a usage point of view.

But then, someone might come up with a good use case that we have not been exposed to yet.

like image 70
R Sahu Avatar answered Oct 23 '25 19:10

R Sahu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!