The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

265818 (18) [Avatar] Offline
#1
public:
// …
operator const decltype(m_computation())& () const
{
std::call_once(m_value_flag, [this] {
m_value = m_computation();
});
return m_cache;
}
};

1) m_value is not defined
2) m_value_flag is not initialized in the lazy_val constructor
Ivan Cukic (104) [Avatar] Offline
#2
Thanks for this. The variable name should be m_cache (it is m_value in the code examples, and that name leaked into the pdf) - I'll fix that when I get the preprint pdfs.

std::once_flag m_value_flag is default-constructed, so that part is fine.