2011-04-04から1日間の記事一覧

動的に複数の型を返す関数

boost.variant を使用すれば、簡単にエミュレート出来ました。 #include <iostream> #include <string> #include <utility> #include <boost/variant.hpp> typedef boost::variant<int, std::string, std::pair<int, std::string> > var_type; var_type func(int n){ switch(n){ case 0: return std::string("string"); case 1: return 10; defaul…</int,></boost/variant.hpp></utility></string></iostream>