[boost]Boost C++ Libraryのお勉強その9
boost::hash
hash関数。興味ないので飛ばす。
boost::fusion
tupleは各要素の型が違うのでSTLのアルゴリズムが使えないので、その辺に対応したもの。
#include <iostream> #include <string> #include <boost/fusion/tuple.hpp> #include <boost/fusion/algorithm.hpp> struct Print { template < typename T > void operator () (T & x) const { std::cout << x << std::endl; } }; int main(void) { boost::fusion::tuple < int, std::string > t(1, "alfa"); boost::fusion::for_each(t, Print()); return 0; }
1 alfa
discards qualifiersとかいうコンパイルエラーが、関数をconstにしてないという意味なのに気がつかず、かなり時間を消費してしまった。