44 points · by davikr · 3y ago · 25 comments
template <typename T>
struct optional {
// One version of value which works for everything
template <class Self>
constexpr auto&& value(this Self&& self) {
if (self.has_value()) {
return std::forward<Self>(self).m_value;
}
throw bad_optional_access();
}
The fact that I can read this and don't even find it that terrible is proof that C++ has permanently damaged my brain.mind you, i feel much the same regarding rust syntax.
Yes, it is, to be diplomatic, highly imperfect, but working to avoid breaking existing code is one reason C++ is so successful.
There is no product that is done, and keeps being used ad infinitum.
By the way, C23 just has been ratified, last COBOL standard is coming this year as well, and Fortran was last updated in 2018.
https://en.cppreference.com/w/c/23
Meanwhile C++ just added for loop scoped typedefs.
for (typedef int Points; Points points : pointsScored) {
std::cout << "Jokic scored " << points << '\n';
}Note that in the time C++ had 5 updates, Python has had 10 releases and Java has had 14!
https://thephd.dev/lambdas-nested-functions-block-expression...
https://thephd.dev/c-the-improvements-june-september-virtual...
https://thephd.dev/ever-closer-c23-improvements
Only a small overview, I lost the link to the PDF with the whole set of language proposals for C2X.