Skip to content

Instantly share code, notes, and snippets.

@guyboltonking
Last active December 16, 2015 07:38
Show Gist options
  • Save guyboltonking/5399827 to your computer and use it in GitHub Desktop.
Save guyboltonking/5399827 to your computer and use it in GitHub Desktop.
Fluent C++; in response to a challenge from Russel Winder's lightning talk at ACCU 2013
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/numeric.hpp>
#include <iostream>
using namespace boost;
using namespace boost::adaptors;
using namespace std;
int main()
{
std::cout <<
accumulate(
irange(0, 100) |
filtered([](int i) { return !(i % 7); }) |
transformed([](int i) { return i * i; }),
0)
<< std::endl;
return 0;
}
all: run-boost-range
run-boost-range: boost-range
./boost-range
boost-range: boost-range.cpp
clang++ -std=c++0x -Iboost_1_53_0 -o boost-range boost-range.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment