Dec
2
comment How to deal with branch prediction when using a switch case in CPU emulation
For anyone interested, this technique is commonly known as "Label as Values" and is supported in gcc and clang.
Nov
29
awarded Popular Question
Nov
25
comment Banking system in C++
What is the proper way to store gender in 2019 actually would be an interesting discussion on its own. I am not sure the proper place to have it though.
Nov
21
accepted Is it possible to enable only specific C++ language features in gcc?
Nov
20
asked Is it possible to enable only specific C++ language features in gcc?
Nov
14
comment With memory_order_relaxed how is total order of modification of an atomic variable assured on typical architectures?
Should be noted that the current question is very different to the pre-edit question, which is why this answer does not fit.
Nov
14
comment With memory_order_relaxed how is total order of modification of an atomic variable assured on typical architectures?
@listerreg You really should move your edit to a new question. The question as it is now, about specific code, is qualitatively very different from the original which mainly about how memory_order_relaxed should be interpreted.
Nov
14
comment With memory_order_relaxed how is total order of modification of an atomic variable assured on typical architectures?
@listerreg What compiler flags are you using? Compiler explorer is generating explicit memory fences at -O0 but at -O1 and higher is using only mov as expected. godbolt.org/z/vh-qCw
Nov
13
awarded Yearling
Nov
13
awarded Yearling
Nov
13
awarded Yearling
Nov
13
awarded Yearling
Nov
13
awarded Yearling
Nov
12
revised With memory_order_relaxed how is total order of modification of an atomic variable assured on typical architectures?
added 115 characters in body
Nov
12
answered With memory_order_relaxed how is total order of modification of an atomic variable assured on typical architectures?
Oct
31
answered Ternary operator vs if statement: compiler optimization
Oct
24
comment How to draw card from deck without repeating in C?
You might want to search the "Kunth Shuffle". The general way to do this is to "draw" a random card by picking a random card and then swapping it with the last card -- then reducing the size of the deck by one. Which means SIZE would no longer be a constant.
Oct
12
comment C sizeof calculation run-time, compile-time
I don't think there is any interpretation that makes this slide make sense. Even at run-time unless you want to dig into the details of the memory allocator you have no idea how much memory was reserved -- just that it was at least 10*sizeof(int) bytes.
Oct
11
answered Properly Pass an Array to a Function c++
Sep
27
awarded Yearling
1 2 3 4 5