tuples_tests.cpp

来自「Boost provides free peer-reviewed portab」· C++ 代码 · 共 57 行

CPP
57
字号
/*=============================================================================    Phoenix V1.2.1    Copyright (c) 2001-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 <iostream>#include <string>#include <boost/detail/lightweight_test.hpp>#include <boost/spirit/include/phoenix1_tuples.hpp>using namespace std;using namespace phoenix;using namespace phoenix;using namespace phoenix::tuple_index_names;intmain(){    {        typedef tuple<int, char> tuple_t;        tuple_t ttt(3, 'c');        tuple_element<0, tuple_t>::type& e0 = ttt[_1];        tuple_element<1, tuple_t>::type& e1 = ttt[_2];        BOOST_TEST(e0 == 3);        BOOST_TEST(e1 == 'c');        cout << e0 << endl;        cout << e1 << endl;    }    {        typedef tuple<int, char, char const*> tuple_t;        tuple_t ttt(3, 'c', "hello world");        cout << ttt.length << endl;        tuple_element<0, tuple_t>::type& e0 = ttt[_1];        tuple_element<1, tuple_t>::type& e1 = ttt[_2];        tuple_element<2, tuple_t>::type& e2 = ttt[_3];        BOOST_TEST(e0 == 3);        BOOST_TEST(e1 == 'c');        BOOST_TEST(string(e2) == "hello world");        cout << e0 << endl;        cout << e1 << endl;        cout << e2 << endl;    }    return boost::report_errors();    }

⌨️ 快捷键说明

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