tupleの要素参照

東方算程譚 - 型推論のオマケ


TR1のtupleにはメンバ関数版のget()がない

#include <string>
#include <boost/tr1/tuple.hpp> // C++0xでは<tuple>

using namespace std;
using namespace std::tr1;

int main()
{
    tuple<int, int, string> person = make_tuple(1, 22, "Akira");

    ++person.get<0>(); // エラー!
    ++get<0>(person);  // OK

    return 0;
}