2015-03-05から1日間の記事一覧

無名構造体を名前付き tuple として使う

C++

例えばユーザ名,Eメール,IDの3つの値を一気に返したいとき,C++ では std::tuple が使えます. #include <string> #include <tuple> using std::operator""s; auto get_user() { // std::tuple<std::string, std::string, int> return std::make_tuple("Linda"s, "foo@bar.com"s, 17); // name, email, id</std::string,></tuple></string>…