String, Y U NO construct with size_t?


#1

On systems where size_t is declared as long unsigned int, this code fails to compile:

size_t bytes;
String (bytes);

The errors are :

ripple_KeyvaDB.cpp:594:9: error: call of overloaded 'String(long unsigned int)' is ambiguous
ripple_KeyvaDB.cpp:594:9: note: candidates are:
beast_String.h:931:14: note: beast::String::String(double)
beast_String.h:925:14: note: beast::String::String(float)
beast_String.h:919:14: note: beast::String::String(beast::uint64)
beast_String.h:914:14: note: beast::String::String(beast::int64)
beast_String.h:909:14: note: beast::String::String(short unsigned int)
beast_String.h:904:14: note: beast::String::String(short int)
beast_String.h:899:14: note: beast::String::String(unsigned int)
beast_String.h:894:14: note: beast::String::String(int)
beast_String.h:154:5: note: beast::String::String(const string&) <near match>
beast_String.h:154:5: note:   no known conversion for argument 1 from 'long unsigned int' to 'const string& {aka const std::basic_string<char>&}'
beast_String.h:112:5: note: beast::String::String(const wchar_t*) <near match>
beast_String.h:112:5: note:   no known conversion for argument 1 from 'long unsigned int' to 'const wchar_t*'
beast_String.h:89:5: note: beast::String::String(const char*) <near match>
beast_String.h:89:5: note:   no known conversion for argument 1 from 'long unsigned int' to 'const char*'
beast_String.h:70:5: note: beast::String::String(const beast::String&)

#2

Because MSVC.

I have attempted to add that overload in the past, but it just confuses all of the older MS compilers, which use a typedef to define size_t as int, so it thinks you’re multiply-defining the constructor. And IIRC trying to use #ifdefs to only enable the overload on proper compilers caused other knock-on problems… It was certainly a total can of worms, I’m afraid. One day, when everyone’s on VC2010 and later, I’ll bring it back.


Now that's 2017... are we dropping C++98?