Conditional based on variable type?

IMO, using 'const' references for passing simple numeric data types adds nothing but noise. Since C++ just does pass by value for these types, this is equivalent:

size_t getCharLength(int i) {
size_t getCharLength(float f, uint8_t dec = 2) {
size_t getCharLength(double d, uint8_t dec = 2) {

And, there's really no need for this anyway:

size_t getCharLength(float, uint8_t dec = 2) {

An argument of type float would be implicitly cast to a double. So just have that one.

1 Like