当前位置: 首页>>代码示例>>C++>>正文


C++ weak_ptr::reset方法代码示例

本文整理汇总了C++中boost::weak_ptr::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ weak_ptr::reset方法的具体用法?C++ weak_ptr::reset怎么用?C++ weak_ptr::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::weak_ptr的用法示例。


在下文中一共展示了weak_ptr::reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: weak_shared

void weak_shared(
    boost::weak_ptr<FIRST>& first, 
    boost::shared_ptr<SECOND>& second
){
    const char * testfile = boost::archive::tmpnam(NULL);
    BOOST_REQUIRE(NULL != testfile);
    int firstm = first.lock()->m_x;
    int secondm = second->m_x;
    save2(testfile, first, second);

    // Clear the pointers, thereby destroying the objects they contain
    first.reset();
    second.reset();

    load2(testfile, first, second);

    // Check data member
    BOOST_CHECK(firstm == first.lock()->m_x);
    BOOST_CHECK(secondm == second->m_x);
    // Check pointer to vtable
    BOOST_CHECK(boost::dynamic_pointer_cast<Sub>(first.lock()));
    BOOST_CHECK(boost::dynamic_pointer_cast<Sub>(second));

    std::remove(testfile);
}
开发者ID:Ruinland,项目名称:boost-doc-zh,代码行数:25,代码来源:test_shared_ptr_multi_base.cpp

示例2: save_and_load3

void save_and_load3(
    boost::shared_ptr<A>& first, 
    boost::shared_ptr<A>& second,
    boost::weak_ptr<A>& third
){
    const char * testfile = boost::archive::tmpnam(NULL);
    BOOST_REQUIRE(NULL != testfile);

    save3(testfile, first, second, third);

    // Clear the pointers, thereby destroying the objects they contain
    first.reset();
    second.reset();
    third.reset();

    load3(testfile, first, second, third);

    BOOST_CHECK(first == second);
    BOOST_CHECK(first == third.lock());
    std::remove(testfile);
}
开发者ID:Ruinland,项目名称:boost-doc-zh,代码行数:21,代码来源:test_shared_ptr.cpp


注:本文中的boost::weak_ptr::reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。