9 ms·
Modern C++: 7 Ways to Fake It Until You Have It
- saagarjha 8y agoThree of these are essentially documentation changes. It goes to show that having readable code that makes your intentions explicit is something that C++ has put a focus in recent versions.
- gruez 8y ago>just visit a reference website such as cppreference.com, grab their implementation This is how you get your employer sued for copyright infringement
- roblabla 8y agoSaid no one ever. https://en.cppreference.com/w/Cppreference:FAQ https://en.cppreference.com/w/Cppreference:FAQ This states that the website's contents are licensed under CC-BY-SA and GFDL, both basically just requiring a link-back to the source. Furthermore, example implementations in reference websites are basically meant to be copy pasted. That's, like, the whole point of their existence.
- jakear 8y agoBut in the event you modify it you do have to share those modifications.
- chris_wot 8y agoIf you modify it, then it's not going to be the C++11 feature you are emulating.
- Someone 8y agoThat’s not just a link-back. Maintaining even one such text fragment across the history of a project already is hard. With every edit of the file, you’ll have to evaluate whether the gist of the original code still is there. Let’s say somebody copy-pastes half an example somewhere else. Should that have a link back, too? I think, the smaller the fragment copied, the harder this is.
- saagarjha 8y agocppreference is CC-BY-SA.
- blt 8y agoIf you're going to put all that modern c++ in comments, might as well use a macro or special token so you can uncomment them automatically when you switch to a newer compiler.
- ilugaslifk 8y agoI know this is not quite on topic, but: Giving some particular construct in your language the official name "Concepts" is just unbelievably fucking atrociously stupid. Inexplicably greedy and needlessly destructive. Say what you will about Haskell's user-hostile jargon, but even they had the sense to rename a concept that was originally called "Idiom". (now "Applicative")
- phendrenad2 8y agoAs a teen, I was introduced to C++ by a friend (who was trying to get me to stop programming in BASIC). We had a serious bit of confusion for a moment when I couldn't understand where he was watching/attending/accessing these "classes". Imagine how much more fun we could have had if they had "concepts" in the language back then!
- AstralStorm 8y agoApplicative is actually a lying name as it has little to do with Applicative category in maths. (an Arrow does, is a subkind of mathematical applicatives) It is in the same category of lies like C++ calling its thing a class. (except C++ does not try to have math background) I prefer a common name to a wrong and confusing name.
- stochastic_monk 8y agoHow is a C++ not a class? It’s a class of objects satisfying certain operations and possessing certain attributes.
- jholman 8y agoIs it worse than calling your auto-resizing-sequence type "vector", even though a vector is properly a tuple of (arbitrary) fixed size, and is incomparable with another thing of any other size? (okay, I guess it might be worse than that)
- stochastic_monk 8y agoYes, because vector is a library, not part of the core language itself.
- chris_wot 8y agoInteresting - LibreOffice handled the =delete by setting it as a macro: https://cgit.freedesktop.org/libreoffice/core/commit/?id=20b720ba3790d657ea3112fde0678c262908a1b6 https://cgit.freedesktop.org/libreoffice/core/commit/?id=20b... Other goodies: SAL_FALLTHROUGH for [[fallthrough]] - see https://opengrok.libreoffice.org/xref/core/include/sal/types.h https://opengrok.libreoffice.org/xref/core/include/sal/types...
- crazy_monkey 8y agoModern C++ is an oxymoron.
- laythea 8y agoI would argue that sprinkling your C++ version X code with equivalent C++ version Y code commented out is an indication that you may have too much time on your hands :) Seriously though, in my opinion, it makes the code horrible to read. Comments were invented to provide a programmer to programmer communication method. Stick with 1 C++ version (even that is a lot!). Migrate code slowly or not at all (there is very rarely a solid justification to rewrite working production code), and remember anything you rewrite will need fully tested (and you may still miss some edge cases). Your fellow programmer and team will thank you.