The very first sentence contains a typo ‘used-defined’ which should be changed to ‘user-defined’. The second paragraph contains another typo ‘so you can write R”(\d+)” ‘ which should be changed to ‘so you can write R”(\d+)” ‘
Thanks Daniel! Do you know of any practical applications for operator””? Operator overloading has become frowned upon for its obscurity, but this one has the potential to carry meaningful names.
I think that’s different from standard operator overloading. You have to specify a suffix, so you can’t use it by accident.
Do you know of any practical applications for operator””?
We use it in the simdjson library.
Marcussays:
Off topic, but what’s your opinion of adding operator overloading to C, in a way that the user would name the function that implements that operator, and therefore doesn’t require name mangling?
Where UTF8String_Init is a previously declared function.
Implementation details could still be hidden, the _Operator declaration could be in a header too, and no name mangling necessary since the function has already been named by the programmer.
No need for a class to contain it either, since the types could be desuced from the parameters of the named function e.g: UTF8String UTF8String_Init(char8_t *Characters);
And for strings, I don’t see why there couldn’t be multiple variants for the same operator.
The very first sentence contains a typo ‘used-defined’ which should be changed to ‘user-defined’. The second paragraph contains another typo ‘so you can write R”(\d+)” ‘ which should be changed to ‘so you can write R”(\d+)” ‘
Thanks.
Thanks Daniel! Do you know of any practical applications for operator””? Operator overloading has become frowned upon for its obscurity, but this one has the potential to carry meaningful names.
I think that’s different from standard operator overloading. You have to specify a suffix, so you can’t use it by accident.
We use it in the simdjson library.
Off topic, but what’s your opinion of adding operator overloading to C, in a way that the user would name the function that implements that operator, and therefore doesn’t require name mangling?
It’s an idea I’ve been kicking around.
Operator overloading in C or in C++?
In regular, old fashioned C.
I’m thinking something like: _Operator = UTF8String_Init;
Where UTF8String_Init is a previously declared function.
Implementation details could still be hidden, the _Operator declaration could be in a header too, and no name mangling necessary since the function has already been named by the programmer.
No need for a class to contain it either, since the types could be desuced from the parameters of the named function e.g: UTF8String UTF8String_Init(char8_t *Characters);
And for strings, I don’t see why there couldn’t be multiple variants for the same operator.
Like:
UTF8String UTF8String_InitFromChars(char8_t *Chars);
UTF8String UTF8String_InitFromChar(char8_t Char);
_Overload = UTF8String_InitFromChar;
_Overload = UTF8String_InitFromChars;
Basically, soft function overloading, but with better names.