

That’s only for C++, as far as I can tell that struct is valid C
That’s only for C++, as far as I can tell that struct is valid C
Relatable tbh
Concepts are already here - (as of now) they fix a subset of this, and errors messages can still be extremely long.
They’re less like “here’s every single template parameter of the involved types” and more like “this template thingy has many specializations with different constraints, here’s a list of all of them and why none of them are satisfied with your parameters”
Not evil by itself, but if you want to obfuscate C++20 code you can get REALLY creative…
C++, lawful good
Who wouldn’t pity those who make do with a lossy compression image format?
Lua - Portuguese feminine noun for “moon”, coming from the Latin “luna”
Luna - Latin, feminine noun (coincidentally identical to the Italian noun, also feminine)
Yup, Lua is a girl.
VS Codium did that at some point, it probably still does but I haven’t checked
Just tested this: the “original+” code compiles, but does not increment i.
There were two problems:
b(bool)
and b(char)
are ambiguous (quick fix: change the signatures to char b(bool&)
and auto b(char&& v)
);b
functions, even if the constraint is only checked after both, I was unaware of this (fix: define C
immediately before void inc(int&)
).It’s funny that it complains about all of the right stuff (except the ‘int’ thing), but it doesn’t say anything about the concept.
About the ‘int’ literal (which is not a string): cppreference.com has a description on this page about it, ctrl+f “multicharacter literal”.
Just surround your eyes with try {
… } catch(Up& up) { }
, easy fix
Multiple-character char literals evaluate as int, with implementation defined values - it is extremely unreliable, but that particular piece of code should work.
// C++20
#include <concepts>
#include <cstdint>
template <typename T>
concept C = requires (T t) { { b(t) } -> std::same_as<int>; };
char b(bool v) { return char(uintmax_t(v) % 5); }
#define Int jnt=i
auto b(char v) { return 'int'; }
// this increments i:
void inc(int& i) {
auto Int == 1;
using c = decltype(b(jnt));
// edited mistake here: c is a type, not a value
// i += decltype(jnt)(C<decltype(b(c))>);
i += decltype(jnt)(C<decltype(b(c(1)))>);
}
I’m not quite sure it compiles, I wrote this on my phone and with the sheer amount of landmines here making a mistake is almost inevitable.
No, all files are base 256
Isn’t auto
a keyword in C?
Types being declarable as virtual members is something I want to never hear again
In my country, high-schools that teach CS teach (a bastardization of) C++ during second grade.
I think it has to do with the fact that it’s close enough to C that starting with it teaches some of the same basic concepts, while having some QOL that a high-school teacher can’t be bothered to do without.
Of course they drop the language after teaching extremely basic algorithms, such as computing the maximum of an arbitrary set of numeric arguments. At that point, why deal with the hundreds of beginner pitfalls of C++ when C would be way less headache-inducing?
Oh, std::enable_if
is straight up worse, they’re unreadable and don’t work when two function overloads (idk about variables) have the same signature.
I’m not even sure enable_if can do something that constraints can’t at all…
Only to get 1 downvote and no follow-up