Hello Vicente,
On Tue, Dec 25, 2012 at 6:28 PM, Vicente Botet
Felipe Magno de Almeida wrote
Hello,
[snip - source code]
But couldn't this make double construction/double free in C++03 systems if system_category is ran concurrently?
Yes sure, this is always possible zith c++0ยท.
Not always possible. It is only possible for non-PODs. AFAIK.
Do you see a problem with this implementation?
Since it has a race-condition, I would say I see a problem, yes. More so since it is not documented. AFAIK, the normal solution for this is to use call_once. system_category const& create_system_category() { system_category const category; return category; } void init_system_category() { create_system_category(); } once_flag init_flag = BOOST_ONCE_INIT; system_category const& get_system_category() { boost::call_once(init_flag, &init_system_category); return create_system_category(); }
Best, Vicente
Regards, -- Felipe Magno de Almeida