3 ms·
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 l
by trealira 1y 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};
- gpderetta 1y agoC++ hasn't done it this way for nullptr or nullopt, why would it do it for an explicit uninitialized?
- trealira 1y agoI 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 1y agoThat's about the right level of ceremony to request an uninitialized variable.
- Maxatar 1y agoYou're not far off. In C++26 the syntax will be: int x [[indeterminate]]; I'm not kidding here;