1 |
|
---|
2 | // clang++ -std=c++98 -Wall -Wextra -pedantic -I ~/Documents/Ordi/boost-trunk -o main main.cpp
|
---|
3 |
|
---|
4 | #include <boost/range/adaptor/transformed.hpp>
|
---|
5 | #include <boost/spirit/include/karma.hpp>
|
---|
6 | #include <iostream>
|
---|
7 |
|
---|
8 |
|
---|
9 | // Note how the return is made by value instead of by reference.
|
---|
10 | template <typename T> T identity(T const& t) { return t; }
|
---|
11 |
|
---|
12 | int main() {
|
---|
13 | namespace karma = boost::spirit::karma;
|
---|
14 | namespace adaptors = boost::adaptors;
|
---|
15 |
|
---|
16 | int ints[] = {0, 1, 2, 3, 4};
|
---|
17 | std::cout << karma::format(karma::int_ % ' '
|
---|
18 | , ints | adaptors::transformed(&identity<int>));
|
---|
19 | }
|
---|