
Leftpad C++ - zelcon
https://gist.github.com/zelcon5/7dc42bf91ea958132a0d
======
Davidbrcz
The code is awful. Just use std::string::insert if you want to pad a string or
std::inserter with begin/end if you want to be more generic

Edit : I actually did a PR on the code. Wait & see

------
Kristine1975
This is really not how you should write C++ in 2016:

\- Manual memory management

\- NULL-terminated strings instead of std::string and/or a string_view class

~~~
zelcon
How is it not clear by my using ONLY standard C library headers that I am NOT
trying to write "modern C++"?

The STL has its uses…when you're writing a high level program, for example,
that queries a database or when you need to pivot matrices for rendering some
graphics. But if you're writing a string manipulating function that's
presumably going to be called tons of times, it makes no sense to draw in big
monsters like the STL. It's like bringing a jackhammer to nail a picture on
drywall.

As for manual memory management, this is C++, not Python. If you're willing to
use smart pointers, then you shouldn't even be using C++ because that
sacrifices determinism and performance just as much or more than GC. If I
wanted that kind of software, I would just use a much quicker-to-write
language like Java/Go/CL.

~~~
Kristine1975
When you're writing a string manipulation function that is called a lot of
times you also don't allocate memory. And GC isn't necessarily slower than
manual memory management. And std::unique_ptr is _never_ slower than manual
memory management, since it does exactly the same thing.

