std :: atomic是否保证int,float等类型的初始化初始化为0 / 0.0?

时间:2016-04-15 04:20:13

标签: c++11 initialization stdatomic

std::atomic<basic_type>创建为类成员而没有明确初始化时,basic_type是否保证class Foo { public: std::atomic<int> bar; }; int main() { Foo foo; return foo.bar; //foo.bar guaranteed to be 0? } 的值为0 / 0.0(以适用者为准):

  • int / uint / short / ushort / etc ...
  • 和; float / double

示例:

<!--INCLUDE HEADER-->
<?php include 'includes/header.php';?>

<!--LOAD CONTET-->
<?php
/*if page is not set, redirect to index*/
if(!isset($_GET['page']) || strlen($_GET['page']) == 0)
{
    header("Location: index.php");
    die();
}
/*if page is set*/
else
{
    /*search page on contet directory*/
    $page = 'content/'.$_GET['page'].'.php';

    /*if page not found on content directory, redirect to index*/
    if(!glob($page))
    {
        header("Location: index.php");
        die();
    }
    /*if page is found, load as subpage*/
    else
    {
?>
    <main class = "<?php echo basename($page, '.php'); ?>">
        <?php include $page;?>
    </main>      
<?php
    }
}
?>

<!--INCLUDE FOOTER-->
<?php include 'includes/footer.php';?>

1 个答案:

答案 0 :(得分:1)

来自std::atomic default constructor的cppreference文档:

  

默认构造函数很简单:不进行初始化   除了静态和线程局部对象的零初始化。   std :: atomic_init可用于完成初始化。

因此,在您的情况下,您将获得与仅声明"routing": { "config": { "routerClass": "sap.m.routing.Router", "viewType": "XML", "transition": "show", "viewPath": "InvestigateOPA.view", "controlAggregation": "pages", "controlId": "app" },

相同的保证