On 06/19/2015 07:03 PM, Niall Douglas wrote:
https://github.com/ned14/boost.spinlock/blob/master/include/boost/spinlock/m...
This starts with the words "The world's most simple C++ monad" followed by 1200 lines of code... makes one scared of monads. Here are some random throughts I had while reading the code. Minor comment, consider letting monad_error inherit from system_error instead of logic_error. When throwing monad_error, you cast to int (presumably to satisfy some compiler.) Can't you simply use make_error_code() instead? That will also ensure that you set the correct category. Why does one of the value_storage constructors call abort() rather than throwing an exception? Why does monad::get_error() throw on no_state, rather than simply returning an error_code that says so? Is there any difference between monad::get() and monad::value()? If they are synonyms, then you may consider removing monad::get() to keep the class interface smaller, and instead overload std/boost::get().