• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
5Build a Simple Program Using Boost
6==================================
7
8To keep things simple, let's start by using a header-only library.
9The following program reads a sequence of integers from standard
10input, uses Boost.Lambda to multiply each number by three, and
11writes 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
27Copy the text of this program into a file called ``example.cpp``.
28
29