]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Copyright David Abrahams 2006. Distributed under the Boost |
2 | .. Software License, Version 1.0. (See accompanying | |
3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
4 | ||
5 | Build a Simple Program Using Boost | |
6 | ================================== | |
7 | ||
8 | To keep things simple, let's start by using a header-only library. | |
9 | The following program reads a sequence of integers from standard | |
10 | input, uses Boost.Lambda to multiply each number by three, and | |
11 | writes them to standard output:: | |
12 | ||
13 | #include <boost/lambda/lambda.hpp> | |
14 | #include <iostream> | |
15 | #include <iterator> | |
16 | #include <algorithm> | |
17 | ||
18 | int main() | |
19 | { | |
20 | using namespace boost::lambda; | |
21 | typedef std::istream_iterator<int> in; | |
22 | ||
23 | std::for_each( | |
24 | in(std::cin), in(), std::cout << (_1 * 3) << " " ); | |
25 | } | |
26 | ||
27 | Copy the text of this program into a file called ``example.cpp``. | |
28 |