I seem to have found something that clang and gcc disagree on. Here's the code:This successfully compiles with gcc 7.4.0 but fails with clang 7.0.0 with this error message:
I am learning pointers and arrays in C and Here is a question that confused me for a while:So the name of a 1D int array is a constant pointer to int, which points to the first element in that array. So when we evaluate the name of a 1D...
Suppose we have a plain array (or other container which support range based loops):Using indexes or iterators we can loop over odd elements increasing the index by two:
Let's say I have the following struct:and the following vector:Now, I want to call something like collect(v, X) and get a std::vector that contains the X values from the original struct vetor in it, for example:
In standard jargon of C and C++, the phrase "atomic object" means "object of atomic type," does it not?
I have a string, from which I want to remove the whitespaces between the numbers:the expected/desired result would be:
I currently working with an old code that needs to run a 32-bit system. During this work I stumbled across an issue that (out of academic interest) I would like to understand the cause of.
I've defined an operator<< output function for std::pair instances, for use by some unit tests that want to print the values if they don't watch what's expected. My test code also has pairs that are held as members of another class that has its own operator<< — specifically boost::optional, but...
Basically, I am trying to convert what appears to be an array of integer values stored in a string type.
I have a 16 bits unsigned variable. I need to split it in 8 bits chunks.Is doing the following enough: