NUL char in strings in C++
std::string is not a null terminated string. If you want to empty it use the clear() method. If you want to remove an element of the string use the erase() method.
std::string is not a null terminated string. If you want to empty it use the clear() method. If you want to remove an element of the string use the erase() method.
Boost is an open source project so the way I see it there are 2 options: Complain. Either write a bug report or get on the mailing list and suggest an enhancement or both. If the community thinks you have a good point, someone might take it on Do 1, then do something about it. … Read more
Why are you loading the old flags value twice in your CAS loops? The first time is by flags.load(), and the second by the compare_exchange_weak(), which the standard specifies on CAS failure will load the previous value into the first argument, which in this case is flagsNow. According to http://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange, “Otherwise, loads the actual value … Read more
NOTE: I opened a question here about whether OPs code is actually valid. My rewritten example below will work in any case. but I would like to know if the code is legal C++11 It is, although the default template argument may be considered a bit unusual. I personally like the following style better, which … Read more
(providing my own answer… I’ll wait for few days and if there are no problems with it — I’ll mark it as accepted) I spent some time investigating this and here is what I unearthed: C++ standard does not specify what is going to happen in this case Clang and GCC seem to use C++ … Read more
My system is set up as follows (Debian testing): libstdc++-7-dev: Installed: 7.2.0-16 libc++-dev: Installed: 3.5-2 clang: Installed: 1:3.8-37 g++: Installed: 4:7.2.0-1d1 I can confirm the bug when using libstdc++: g++ -o pois_gcc -std=c++11 pois.cpp clang++ -o pois_clang -std=c++11 -stdlib=libstdc++ pois.cpp clang++ -o pois_clang_libc -std=c++11 -stdlib=libc++ pois.cpp Result:
The logical argument is as follows std::priority_queue is a container adaptor; basic memory considerations make the back the preferred place for modifications (with pop_back() and push_back()) for sequence containers such as std::vector. the priority_queue primitives are based on std::make_heap (constructor), std::pop_heap + container::pop_back (priority_queue::pop) and on container::push_back + std::push_heap (priority_queue::push) pop_heap will take the front … Read more
There is a library working group unresolved[1] issue on this uniform_int_distribution<unsigned char> should be permitted and it says, amongst other things: I am not aware of anything in <random> that works with 16-bit integers but fails with 8-bit integers, so I suspect that IntType and UIntType could simply be extended to permit the char family. … Read more
Since C++11 you can use std::tuple_size on std::array to obtain the size as a compile time constant. See http://en.cppreference.com/w/cpp/container/array/tuple_size
Yes, it is apparently allowed. According to the latest draft of the upcoming standard I could find, it is stated that A template-argument for a template template-parameter shall be the name of a class template or an alias template […]. However, alias templates seems very seldomly supported at the moment, so you might have some … Read more