Comment by HolyBlackCat on What is undefined behaviour in these pointer...
@PepijnKramer Do you have a source for that? Note that OP's code doesn't rely on implicitly starting object's lifetime.
View ArticleComment by HolyBlackCat on What is undefined behaviour in these pointer...
@JanSchultke Yeah, just edited that in. My understanding is that casting to [u]intptr_t lets you compute the offset safely (in practice at least), but it's not enough to bless the + to jump between...
View ArticleComment by HolyBlackCat on How to write a getter which accesses a...
Your operator=s leak the existing buffer, I believe.
View ArticleComment by HolyBlackCat on Accessing an out of range element in an array
You need to manually opt in bounds checks (which you usually only enable while developing, not in releases). Look up "address sanitizer".
View ArticleComment by HolyBlackCat on How am I linking?
"best way to link a library is statically" This isn't so simple. You can get away with static linking on Windows, but then your users can't update the libraries themselves if needed, and the only...
View ArticleComment by HolyBlackCat on Is there LTS for C++, if not, how?
There's no single C++ compiler. There are three major ones: Clang, GCC, MSVC. Each of them has stable releases, and older releases presumably get some minimal updates.
View ArticleComment by HolyBlackCat on MakeFile is not adding CPP Include flags correctly
Something doesn't add up. Are you sure you're running this exact makefile, using exactly make -n?
View ArticleComment by HolyBlackCat on Why don't free functions in implementation files...
@303 I expect the linker to merge inline functions (different copies of the same function) even when not inlined.
View ArticleComment by HolyBlackCat on Ternary Operator use on returning answer Vector
Seems like an arbitrary limitation of ? :. I don't see any reason why it couldn't deduce the type of {-1} from the type of the other operand, but apparently that's not allowed.
View ArticleComment by HolyBlackCat on Why do we have to add multiple numbers in...
Assuming arr stores integers, there should be no difference. If there was a difference, a sensible programmer would include a comment explaining it.
View ArticleComment by HolyBlackCat on Long Compiling and Execution Time
Try disabling your antivirus.
View ArticleComment by HolyBlackCat on _CharT_alloc_type is what,how it work,i can't see...
Please add the code you're talking about as text, and tell where you found it (which C++ standard library you're using, or if you don't know, say what compiler you're using).
View ArticleComment by HolyBlackCat on An Exact way to distinguish is this validation...
Why does it matter how you call it?
View ArticleComment by HolyBlackCat on In C, when I use the malloc() function, it appears...
It's unlikely that malloc is bugged, more likely your code is bugged. Try enabling the address sanitizer, see if it catches it.
View ArticleComment by HolyBlackCat on C++ OpenCV - How to display a resized video frame...
Please don't add the solution to the question. Post it as an answer below, and press the checkmark next to it to mark your question as solved.
View ArticleComment by HolyBlackCat on How can i use class objects as parameters in other...
First, you have to get rid of the circular includes (look it up), probably by removing both and replacing them with foward declarations. Second, every function parameter where you accept a...
View ArticleComment by HolyBlackCat on Is there an opposite of std::format?
There's scnlib, but I've never tried it myself.
View ArticleComment by HolyBlackCat on Cannot open include file: 'SDL/SDL.h': No such...
How are we supposed to help if you didn't explain what you actually did? Either the tutorial was wrong, or you didn't follow it correctly.
View ArticleComment by HolyBlackCat on Is it mandatory to have a function template to...
I believe this needs to be non-const auto &&values, some standard views have non-const begin()/end(). Also ranges::input_range is probably a bit better than just range.
View Article