リストから先頭N個を取得する
#include <iostream> #include <iterator> #include <algorithm> #include <boost/fcpp/prelude.hpp> using namespace std; using namespace boost::fcpp; int main() { list<int> ls = take(5, enum_from(1)); // 1,2,3,4,5,6,7,8,9,...の無限リストから先頭5個を取得 copy(ls.begin(), ls.end(), ostream_iterator<int>(cout, ",")); // 1,2,3,4,5 return 0; }