C++11 atomic memory ordering – is this a correct usage of relaxed (release-consume) ordering?

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

Bug in the C++ standard library in std::poisson_distribution?

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 reason of using `std::greater` for creating min heap via `priority_queue`

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

Why Aren’t `std::uniform_int_distribution` and `std::uniform_int_distribution` Allowed?

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

Can I use template aliases as template template parameters?

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