⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tuple_copy_tests.cpp

📁 C++的一个好库。。。现在很流行
💻 CPP
字号:
/*=============================================================================
    Copyright (C) 1999-2003 Jaakko J鋜vi
    Copyright (c) 2003 Joel de Guzman

    Use, modification and distribution is subject to the Boost Software
    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
    http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/spirit/fusion/sequence/tuple.hpp>
#include <boost/spirit/fusion/sequence/get.hpp>

namespace
{
    // classes with different kinds of conversions
    class AA {};
    class BB : public AA {};
    struct CC { CC() {} CC(const BB&) {} };
    struct DD { operator CC() const { return CC(); }; };
}

int
main()
{
    using namespace boost::fusion;

    tuple<int, char> t1(4, 'a');
    tuple<int, char> t2(5, 'b');
    t2 = t1;
    BOOST_TEST(get<0>(t1) == get<0>(t2));
    BOOST_TEST(get<1>(t1) == get<1>(t2));

    tuple<long, std::string> t3(2, "a");
    t3 = t1;
    BOOST_TEST((double)get<0>(t1) == get<0>(t3));
    BOOST_TEST(get<1>(t1) == get<1>(t3)[0]);

    // testing copy and assignment with implicit conversions
    // between elements testing tie

    tuple<char, BB*, BB, DD> t;
    tuple<int, AA*, CC, CC> a(t);
    a = t;

    int i; char c; double d;
    tuple<int&, char&, double&>(i, c, d) = tuple<int, char, double>(1, 'a', 5.5);

    BOOST_TEST(i==1);
    BOOST_TEST(c=='a');
    BOOST_TEST(d>5.4 && d<5.6);

    return boost::report_errors();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -