News for hackers. Stuff that matters.
Re:Patching around a C++ crash with a little bit of Lua by tialaramex on Wednesday December 13, 2023 @07:45AM (#38626546)
If I've got a std::string I can totally see passing it as a const reference. If I've got 418 bytes of RAM that I'm slicing up into "strings", how can I make the const &std::string I need from that? I could make a std::string_view easily enough, but the std::string wants to own the memory allocation, and it can't have that because it's mine. So now I'm either allocating and copying (bye bye performance) or I pass char*.

Because C++ loves implicit conversion this works even when the API didn't intend char* because it just calls the constructor on std::string to make one from the pointer. "Hooray"

There are no comments on this comment yet.