Is there a way to have conditional function depending on whether a template parameter is true? Use case: I was making a class that has basically 2 version, 1 basic and 1 adva...
The below code is, by my analysis, doing out-of-bounds access, which is also UB. However, no warning gets triggered despite all major warnings enabled, sanitizers don't detect...
for(auto [dx,dy]: {{0,1},{0,-1},{1,0},{-1,0}}) GCC => error: unable to deduce ‘std::initializer_list<auto>&&’ from ‘{{0, 1}, {0, -1}, {1, 0}, {-1, 0}}’ for(auto [dx,dy]: {...
I saw that GCC is compiling code such that it I call a function (adding 2 nos for example), it passes the arguments using registers instead of the stack. 1. A search tells me ...
I was just wondering, say I have a class X. class X { X(auto _out) : out(_out) {} int func(int x, int y, ...) { // some stuff return out(x,y); } functi...
Hi! So I was planning to add this bookmarklet from site (https://codepen.io/bookmarklets/pen/wZpdzj), but then I noticed that its javascript code is obfuscated, which raises ...
I needed to convert a pointer to a numerical data type. While the uintptr_t type is the recommended approach, is using size_t also enough? (Why I don't prefer the previous is ...
Lately I have been coming across lots of articles from fluentcpp.com and they seem good. Maybe add it to ^ ?
Not to be rude, but isn't the example code given too over-engineered? Is this really what it means to write code in C++20? http://web.archive.org/web/20190110183501/http://er...
In http://digitalvampire.org/blog/index.php/2006/07/31/why-you-shouldnt-use-__attribute__packed/ , why does GCC generate large code for the second function? I can't understand...
What exactly are u referring to? I only know the in-built functions in C++ that can save the state of the object at that time and restore it afterwards. It's not there in C AF...
Kind of a design question: If I am passing integers over a pipe, right now I am doing write(fd[1], &i, sizeof(int)). Is replacing the third with sizeof(i) better? Asking becau...
Well IMO as a end-user of the class, I should not be able to pass func and the decltype be applied automagically. For example, if I had to do sort<decltype(cmp)>(a.begin(), a....
Does anyone use -Wsign-conversion? It gives so many false positives for me that I cannot imagine anyone would find it useful. [For example, I am a heavy user of vectors. Any d...
Is there a good way to get rid of the ugly decltype in template type? https://godbolt.org/z/8Waaez
So what I understood is that for the second case, GCC gets every byte order by order instead of getting the word directly, because it couldn't be sure the word is fully aligne...
That makes sense from the compiler's point of view. But what about dynamic analyzers? At least Valgrind should have detected runtime OOB, no?
Just a thought experiment, but can we write a function that forces compiler errors if it's not elided as dead code, and nothing otherwise?
Does it have misinformation or something?
Why would you want to do that? It is as efficient as copying normally, there is no overhead.