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

C++0xのdecltypeでmapのvalue_typeを取得する方法

C++

こんな感じ #include <type_traits> #include <string> #include <map> using namespace std; int main() { map<string, int> dict; // std::pair<string, int> val = ... remove_reference<decltype(*dict.begin())>::type val = *dict.begin(); return 0; }</decltype(*dict.begin())></string,></string,></map></string></type_traits>