Is publishing of magic statics thread safe?

前端 未结 2 1477
梦如初夏
梦如初夏 2021-01-18 23:04

Imagine I have this:

const string& get_name()
{
static auto* ptr_name=new string(\"Ron\");
return *ptr_name;
}

If multiple threads are

2条回答
  •  情歌与酒
    2021-01-18 23:28

    This is thread safe in C++11 and forward.

    VS-2013 has not yet implemented this part of C++11. VS-14 does:

    http://blogs.msdn.com/b/vcblog/archive/2014/06/11/c-11-14-feature-tables-for-visual-studio-14-ctp1.aspx

提交回复
热议问题