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


C++ boost::move方法代码示例

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


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

示例1: user

// This builds slightly on the previous test by checking that the filesystem
// can be destroyed _after_ the session is moved.  It still isn't a test that
// the filesystem is usable afterwards (though we probably want that
// property too), just that the object is valid (can be destroyed).
//
// In an earlier version, the filesystem destructor tried to use the moved
// session causing a crash.  It's very hard sometimes to ensure the filesystem
// is destroyed before the exact (non-moved) session it came from, so its
// important we allow destruction to happen after moving the session (but
// before moved-to session is destroyed).
BOOST_FIXTURE_TEST_CASE(
    move_session_with_live_filesystem_connection, session_fixture )
{
    session& s = test_session();
    s.authenticate_by_key_files(
        user(), public_key_path(), private_key_path(), "");

    sftp_filesystem fs = s.connect_to_filesystem();
    session s2(move(s));

    // The rules are that the last session must outlive the last FS so moving
    // FS to inner scope ensures this
    sftp_filesystem(move(fs));
}
开发者ID:alamaison,项目名称:ssh2-cpp,代码行数:24,代码来源:filesystem_test.cpp

示例2: create_and_authenticate

running_session create_and_authenticate(
    const wstring& host, unsigned int port, const wstring& user,
    com_ptr<ISftpConsumer> consumer)
{
    running_session session(host, port);

    verify_host_key(host, session, consumer);
    // Legal to fail here, e.g. user refused to accept host key

    authenticate_user(user, session, consumer);
    // Legal to fail here, e.g. wrong password/key

    assert(session.get_session().authenticated());

    return move(session);
}
开发者ID:alamaison,项目名称:swish,代码行数:16,代码来源:authenticated_session.cpp

示例3: session

    {
        connect_socket_to_host(socket, host, port, io);
        return ssh::session(socket.native(), disconnection_message);
    }
}

running_session::running_session(const wstring& host, unsigned int port)
: 
m_io(new io_service(0)), m_socket(new tcp::socket(*m_io)),
m_session(
     session_on_socket(*m_socket, host, port, *m_io, "Swish says goodbye."))
{}

running_session::running_session(BOOST_RV_REF(running_session) other)
:
m_io(move(other.m_io)),
m_socket(move(other.m_socket)), m_session(move(other.m_session)) {}

running_session& running_session::operator=(BOOST_RV_REF(running_session) other)
{
    swap(running_session(move(other)), *this);
    return *this;
}

session& running_session::get_session()
{
    return m_session;
}

bool running_session::is_dead()
{
开发者ID:alamaison,项目名称:swish,代码行数:31,代码来源:running_session.cpp


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