
Modern C++: 7 Ways to Fake It Until You Have It - ristem
https://www.fluentcpp.com/2018/08/31/modern-cpp-fake-it-until-you-have-it/
======
ilugaslifk
I 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")

~~~
jholman
Is 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
Yes, because vector is a library, not part of the core language itself.

~~~
Koshkin
Well, not just some library. (The 'standard library' should be seen as part of
the language.)

~~~
stochastic_monk
True, but there is a huge difference between a standard library feature and a
keyword.

~~~
Koshkin
Not really... Not in the case of _the standard_ library anyway.

~~~
stochastic_monk
A keyword is a more core part of the language than the standard library. I
could re-implement my own vector. I cannot add my own keyword.

~~~
Koshkin
No, you cannot/wouldn't reimplement std::vector (not in the sense you are
implying).

Compiler writers often extend the language with new keywords.

~~~
stochastic_monk
Can you elaborate on the last point? Do you mean things like macros they use,
e.g., concepts lite, or __builtin* functions?

I still feel like a standard container is less fundamental than keywords, but
I value your perspective.

~~~
Koshkin
Yes, built-ins, intrinsics, and extensions.

My original point was simply that std::vector, say, is just as good a
"keyword" as any - perhaps, not because you cannot redefine it but because you
wouldn't, and if you didn't like what it does, you'd use/implement something
else.

------
laythea
I 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.

------
chris_wot
Interesting - LibreOffice handled the =delete by setting it as a macro:

[https://cgit.freedesktop.org/libreoffice/core/commit/?id=20b...](https://cgit.freedesktop.org/libreoffice/core/commit/?id=20b720ba3790d657ea3112fde0678c262908a1b6)

Other goodies:

SAL_FALLTHROUGH for [[fallthrough]] - see
[https://opengrok.libreoffice.org/xref/core/include/sal/types...](https://opengrok.libreoffice.org/xref/core/include/sal/types.h)

------
saagarjha
Three 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.

------
blt
If 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.

------
gruez
>just visit a reference website such as cppreference.com, grab their
implementation

This is how you get your employer sued for copyright infringement

~~~
roblabla
Said 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
But in the event you modify it you do have to share those modifications.

~~~
chris_wot
If you modify it, then it's not going to be the C++11 feature you are
emulating.

