3 ms·
Some of the solutions are not safe (and should be indicated as such). For example MIN/MAX in generic.h are macros so shouldn't be used with functions (and mustn
by DominikD 9y ago
Some of the solutions are not safe (and should be indicated as such). For example MIN/MAX in generic.h are macros so shouldn't be used with functions (and mustn't be used with functions that have side-effects). Macro parameters aren't bracketed either so operator precedence can bite there too.
There's also potential for undefined or implementation-defined behavior (e.g. multiply_by_7() is left shifting signed int). Author's heart is in the right place it's just that his skills aren't necessarily up to the task, I'm afraid.
- mandliya 9y agoedit: Spellings. Thank you for the feedback. Some of the programs here are coded 4 years ago, when I had just started learning C++ and I never revisited them. At that time, I was in university, and this repo was to attract recruiters for internship. I got the job later, and kind of ignored to correct problems. I am sure if these are ran with strict compiler flags there would be many more issues. I will get around and fix it sometime soon.
- DominikD 9y agoSure thing, reading through the repo I understood it was used to learn stuff. But it may not be immediately understood by a novice. And thing with the Internet is: people will start using code from your repo and get into all sorts of issues. It's unlikely you'll smooth this code up. Nobody's got the time, let's be honest here. ;) So I'd recommend that you at least state explicitly that these functions shouldn't be lifted directly unless someone knows what he/she is doing.
- mandliya 9y agoThanks again for the response, I understand it might be better to put a warning note at the top of readme. Thank you again for the advice.