Author: | Wojciech Muła |
---|---|
Added on: | 2015-11-28 |
I wrote:
result += string_utils::pad_left(string, '0');
I forget that pad_left signature is string, int, char and the char parameter has a default value. My mistake, without doubts.
This is another example of dark sides of the implicit conversions. C++ converts between characters and integers seamlessly. These two beast are distinct in the nature. Of course characters are represented by the numbers, however it's an implementation detail.
One can say: you made a mistake and now blame the language. No, I blame language's design. I'm afraid that we end up with something like Integer and int to overcome such problems.
Lesson learned: never use default parameters in public API (surprise!)