August 2017
Intermediate to advanced
438 pages
14h 19m
English
#include <boost/thread/once.hpp>struct postprocessor { typedef std::vector<std::string> answer_t;private: mutable boost::once_flag default_flag_; mutable answer_t default_;
Variables are mutable because we are going to modify them inside const member functions.
public: postprocessor() : default_flag_(BOOST_ONCE_INIT) , default_() {}
// Concurrent calls on the same variable are safe. answer_t act(const std::string& in) const { answer_t ret; if (in.empty()) { // Extremely rare condition. boost::call_once(default_flag_, [this]() ...Read now
Unlock full access