PageRenderTime 87ms CodeModel.GetById 83ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/phoenix/example/all_odds.cpp

http://hadesmem.googlecode.com/
C++ | 35 lines | 23 code | 5 blank | 7 comment | 1 complexity | e334b380dc36da046b2ffa63a58c4d8c MD5 | raw file
 1/*=============================================================================
 2    Copyright (c) 2001-2007 Joel de Guzman
 3
 4    Distributed under the Boost Software License, Version 1.0. (See accompanying 
 5    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 6==============================================================================*/
 7#include <vector>
 8#include <algorithm>
 9#include <iostream>
10#include <boost/phoenix/core.hpp>
11#include <boost/phoenix/operator.hpp>
12#include <boost/phoenix/statement.hpp>
13
14int
15main()
16{
17    using boost::phoenix::if_;
18    using boost::phoenix::arg_names::arg1;
19
20    int init[] = { 2, 10, 4, 5, 1, 6, 8, 3, 9, 7 };
21    std::vector<int> c(init, init + 10);
22    typedef std::vector<int>::iterator iterator;
23
24    //  Print all odd contents of an stl container c
25    std::for_each(c.begin(), c.end(),
26        if_(arg1 % 2 == 1)
27        [
28            std::cout << arg1 << ' '
29        ]
30    );
31
32    std::cout << std::endl;
33
34    return 0;
35}