11 ms·
modern C++ is fine, as long as you don't try to get too clever with return types, move semantics, constexpr and template parameter expansions. They all have th
by nurettin 4y ago
modern C++ is fine, as long as you don't try to get too clever with return types, move semantics, constexpr and template parameter expansions.
They all have their places, but if your code is littered with them, it feels like every line is a puzzle.
Here's an attempt to wrap sqlite in a typesafe manner using template expansion. All very simple C++11. https://github.com/nurettin/pwned/blob/master/sqlsafe/sqlsafe.hpp#L163 https://github.com/nurettin/pwned/blob/master/sqlsafe/sqlsaf...
(some types had to be spelled out because the compilers weren't ready)
Here's some more C++11 without using any of the mentioned complexities https://github.com/nurettin/pwned/blob/master/server/server.hpp#L31 https://github.com/nurettin/pwned/blob/master/server/server....
This shows that simply spelling out your types and not getting crazy with polymorphic metaprogramming makes code much more readable. Ideally, code should just be a bunch of ifs and loops.