identity + decltype でインスタンスからメンバの型を取得する
#include <map> #include <string> using namespace std; int main() { map<int, string> dict; // pair<int, string> value = ... identity<decltype(dict)>::type::value_type value = *dict.begin(); value.first ...; value.second ...; return 0; }
ちなみに std::identity は
namespace std { template <class T> struct identity { typedef T type; }; }