예제 #1
0
파일: main.cpp 프로젝트: Sangil-Lee/MyCode
int main() {

    typedef boost::fusion::vector<
        int, boost::blank, boost::blank, float
    > tup1_t;
    tup1_t tup1(8, boost::blank(), boost::blank(), 0.0);

    boost::fusion::vector<boost::blank, boost::blank> res_na
        = get_nonarithmetics(tup1);
    boost::fusion::vector<int, float> res_a = get_arithmetics(tup1);
    assert(boost::fusion::at_c<0>(res_a) == 8);


    (void)res_na;
}
예제 #2
0
파일: main.cpp 프로젝트: Sangil-Lee/MyCode
int main() {
    tuple_example();
    fusion_tuple_example();
    stringize_tup2_example();

    boost::fusion::vector<cat, int, std::string> tup1(cat(), 0, "_0");
    boost::tuple<cat, int, std::string> tup2(cat(), 0, "_0");
    std::pair<cat, cat> cats;
    boost::array<cat, 10> many_cats;

    std::cout << stringize(tup1) << '\n' 
        << stringize(tup2) << '\n'
        << stringize(cats) << '\n'
        << stringize(many_cats) << '\n';
}
예제 #3
0
파일: main.cpp 프로젝트: jabernet/tuple99
int main(const int argc, const char* argv[])
{
    Tuple<int> i1;
    Tuple<int, int> i2;
    Tuple<int, int, int> i3;
    Tuple<int, int, int, int> i4;
    Tuple<int, int, int, int, int> i5;
    Tuple<int, int, int, int, int, int> i6;

    Tuple<int, float, double, char, std::string> tup1(1, 1.0f, 1.0, '1', "1");
    Tuple<int, float, double, char, std::string> tup2(::make_tuple(2, 2.0f, 2.0, '2', std::string("2")));

    std::cout << tup1.get<0>() << " " << tup1.get<1>() << " " << tup1.get<2>() << " " << tup1.get<3>() << " " << tup1.get<4>() << std::endl;
    std::cout << tup2.get<0>() << " " << tup2.get<1>() << " " << tup2.get<2>() << " " << tup2.get<3>() << " " << tup2.get<4>() << std::endl;

    tup1.set<0>(Tuple<int, int>::Element<0>::type(10));
    tup1.set<4>(std::string("10"));

    std::cout << tup1.get<0>() << " " << tup1.get<1>() << " " << tup1.get<2>() << " " << tup1.get<3>() << " " << tup1.get<4>() << std::endl;

    if(tup1 == tup2)
    {
        std::cout << "WTF!?" << std::endl;
    }

    if (tup1 != tup1)
    {
        std::cout << "WTF!?" << std::endl;
    }

    if (!IsTuple<Tuple<int, float, double, char, std::string> >::value)
    {
        std::cout << "isTuple failed" << std::endl;
    }

    if (IsTuple<int>::value)
    {
        std::cout << "isTuple failed" << std::endl;
    }

    tup1 = tup2;

    make_tuple(1, 2, 3, 4).forEach(Printer());
    std::cout << std::endl;

    if (make_tuple(1) != Tuple<int>(1))
    {
        std::cout << "eq1 failed" << std::endl;
    }
    else
    {
        std::cout << make_tuple(1) << std::endl;
    }
    if (make_tuple(1,2) != Tuple<int, int>(1,2))
    {
        std::cout << "eq2 failed" << std::endl;
    }
    else
    {
        std::cout << make_tuple(1,2) << std::endl;
    }
    if (make_tuple(1, 2, 3) != Tuple<int, int, int>(1, 2, 3))
    {
        std::cout << "eq3 failed" << std::endl;
    }
    else
    {
        std::cout << make_tuple(1,2,3) << std::endl;
    }
    if (make_tuple(1, 2, 3, 4) != Tuple<int, int, int, int>(1, 2, 3, 4))
    {
        std::cout << "eq4 failed" << std::endl;
    }
    else
    {
        std::cout << make_tuple(1,2,3,4) << std::endl;
    }
    if (make_tuple(1, 2, 3, 4, 5) != Tuple<int, int, int, int, int>(1, 2, 3, 4, 5))
    {
        std::cout << "eq5 failed" << std::endl;
    }
    else
    {
        std::cout << make_tuple(1,2,3,4,5) << std::endl;
    }
    if (make_tuple(1, 2, 3, 4, 5, 6) != Tuple<int, int, int, int, int, int>(1, 2, 3, 4, 5, 6))
    {
        std::cout << "eq6 failed" << std::endl;
    }
    else
    {
        std::cout << make_tuple(1,2,3,4,5,6) << std::endl;
    }

    return 0;
}