1/*=============================================================================
2 Copyright (c) 2001-2003 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/function.hpp>
12
13using boost::phoenix::function;
14
15struct is_odd_
16{
17 typedef bool result_type;
18
19 template <typename Arg>
20 bool operator()(Arg arg1) const
21 {
22 return arg1 % 2 == 1;
23 }
24};
25
26function<is_odd_> is_odd;
27
28int
29main()
30{
31 using boost::phoenix::arg_names::arg1;
32
33 int init[] = { 2, 10, 4, 5, 1, 6, 8, 3, 9, 7 };
34 std::vector<int> c(init, init + 10);
35 typedef std::vector<int>::iterator iterator;
36
37 // Find the first odd number in container c
38 iterator it = std::find_if(first: c.begin(), last: c.end(), pred: is_odd(arg1));
39
40 if (it != c.end())
41 std::cout << *it << std::endl; // if found, print the result
42 return 0;
43}
44

source code of boost/libs/phoenix/example/function.cpp