Hrm. C++ supports implicit conversion operators.
So, why the hell doesn’t std::string have one for const char *? That’d eliminate the use of .c_str() when talking to libc and other C libraries, outside of variadic parameters.
@SuperFloppies Probably a newer extension then.
@gudenau Perhaps. Also makes it stupidly easy to have what looks like a C-style cast turn into the implicit invocation of an arbitrary amount of code. One of those “use with care” features.
@SuperFloppies Hmm, would be interesting if there was an operator like ((cast)) instead of (cast) to enable "expensive" casts.
@gudenau ... or a compiler flag to disable implicit conversions. Hrm. Time to look at the compiler manual again...
@SuperFloppies That one would be a little more global, I was thinking a different operator so you can use it sometimes when it is intended.
@SuperFloppies Oh, another thing I wanted to ask you about C++. Can you use that "goes out of scope" operator thing? Don't know the details off the top of my head but I remember it in a Vulkan guide.
@gudenau what do you mean?
@SuperFloppies There was some thing that called cleanup stuff when variables went out of scope. Like a local var would have the cleanup called when the function returned and Objects would have them cleaned up automatically when it was deleted without using the deconstructor.
@SuperFloppies Kind of like `java.lang.ref.Cleaner` but on scope changes not on garbage collection.
@gudenau Hrm. You can enable -Wold-style-cast -Werror, which forces you to use the newer C++ casts instead. Seems to be the only way, short of not defining implicit conversion operators.
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!