String::operator+=(long) has no implementation

While working on some juce bindings, i just found that:

String::operator+= (const long number)

is not declared in the juce_String.cpp resulting in a failed load library because the symbol is undefined.

Thanks for reporting! We’ve added the missing implementation in e195a25.

Since “long” is equivalent to “int”, isn’t this rather pointless? If you want to support all int types, to make compilation easier without casting, then how about:

unsigned int
unsigned long
unsigned short

I think this is one of those cases where the library shouldn’t accommodate every possible data-type.

long definately is not int. and long long is not int64 on some platforms

IIRC the reason why there weren’t overloads for all the types was because of ambiguity in MSVC over size_t vs unsigned long, so it wasn’t possible to have a full set of overloads that worked on all platforms. Now that we don’t support the older MSVC versions that’s probably no longer true.

I was just doing some similar overloading for a class in soul and have to say that in C++17 or later, using some if constexprs inside a templated method is a really neat way of handling all the numeric overload edge-cases inside one function, without needing to resort to overloads or messy template specialisations. :slight_smile:

1 Like

On Windows it definitly is. Both are 32-bit signed integers.

Indeed, so this means we still don’t have a += operator for size_t on windows. Maybe instead of adding one for the ambiguous long, adding one for unsigned int would do the trick.

the fact that it is true in your development platform it doesn’t mean it is for anybody else out there

I was simplyt pointing out that your statement of long != int is simply not true on all platforms. How you turn that into an attack on me is beyond me. We say the same thing, but somehow I’m wrong and you’re right.

attack? :laughing: come on man, take it easy