Skip to content

Instantly share code, notes, and snippets.

@eiiches
Created March 26, 2012 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eiiches/2202505 to your computer and use it in GitHub Desktop.
Save eiiches/2202505 to your computer and use it in GitHub Desktop.
1から100までの整数の和を表示するプログラムを作れ
#include <iostream>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/plus.hpp>
#include <boost/mpl/fold.hpp>
using namespace boost;
int
main(int argc, char **argv)
{
int x = mpl::fold<
mpl::range_c<int, 1, 100 + 1>,
mpl::int_<0>,
mpl::plus<mpl::_, mpl::_>
>::type::value;
std::cout << x << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment