3 ms·
I've never seen anyone use these since they appeared in the spec decades ago. They're as pointless as trigraphs, which I've never seen in the wild either.
by WalterBright 6y ago
I've never seen anyone use these since they appeared in the spec decades ago. They're as pointless as trigraphs, which I've never seen in the wild either.
- jeffbee 6y agoEver seen a real use of `operator"" _X`, the C++11 feature that lets you declare a literal constant like this? int operator"" _km(unsigned long long); auto distance = 42_km; The breadth of crazy features in C++ is really huge, when you dig in.
- WalterBright 6y agoThe equivalent thing in D is, but without a special feature: template _km(ulong v) { enum _km = inKilometers(v); } auto distance = _km!42; It's used by the Sargon library to create a halffloat type: https://digitalmars.com/sargon/halffloat.html https://digitalmars.com/sargon/halffloat.html I haven't seen it used in C++, though my C++ experience post this feature is limited.
- pjmlp 6y agoAll the time, "A safer string"s Declares a std::string constant. While I agree C++ is huge, I doubt anyone would survive a Python, Java, C#, VB.NET, JavaScript, Typescript, Fortran, Ada, Common Lisp, COBOL, C pub quiz, based on the very latest language versions.
- tom_ 6y agohttps://github.com/nlohmann/json/blob/c215b77936591d4fe0aa0a1df737eb944b4ee38b/src/json.hpp#L1122 https://github.com/nlohmann/json/blob/c215b77936591d4fe0aa0a...
- WalterBright 6y agoCongratulations! There's one!
- jcelerier 6y agoOne thing is, for the longest time MSVC did not support them (against the spec like always) so they could not be used if you wanted cross-platform code.