trealira 1 day ago

Nah, they'd never add new syntax like that, given it's inconsistent with the rest of C++.

If they added an explicit uninitialized value representation to the language, I bet it would look something like this:

  int x {std::uninitialized<int>::value};

3
Maxatar 1 day ago

You're not far off. In C++26 the syntax will be:

   int x [[indeterminate]];
I'm not kidding here;

gpderetta 1 day ago

C++ hasn't done it this way for nullptr or nullopt, why would it do it for an explicit uninitialized?

trealira 1 day ago

I guess nullptr was put in there because because because "#define NULL 0" had some bad consequences for C++ and they needed a replacement.

std::nullopt doesn't seem so different to what I was talking about; I guess it's just less verbose. When I wrote that, I was thinking of things like "std::is_same<T1, T2>::value" being there.

tlb 1 day ago

That's about the right level of ceremony to request an uninitialized variable.