Advertisement
obernardovieira

Get array inside tuple inside unordered_map

Oct 7th, 2013
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <utility>
  3. #include <tuple>
  4. #include <unordered_map>
  5. #include <array>
  6.  
  7. typedef std::array<float, 3> arr;
  8. typedef std::tuple<int, int, arr> object;
  9. typedef std::unordered_map<int, object> fmap;
  10.  
  11. int main()
  12. {
  13.     fmap FMap;
  14.     arr maparray;
  15.     maparray[0] = 5.5f;
  16.     maparray[1] = 6.6f;
  17.     maparray[2] = 7.7f;
  18.     auto t1 = std::make_tuple(10,3,maparray);
  19.  
  20.     FMap.insert(fmap::value_type(5,t1));
  21.  
  22.     fmap::iterator j = FMap.find(5);
  23.  
  24.     if(j != FMap.end()) {
  25.         std::cout << "Sim" << std::endl;
  26.         std::cout << std::get<0>(j->second) << std::get<1>(j->second) << std::endl;
  27.         auto ti = std::get<2>(j->second);
  28.         std::cout << std::get<0>(ti) << std::get<1>(ti) << std::get<2>(ti) << std::endl;
  29.     }
  30.     else {
  31.         std::cout << "Nao" << std::endl;
  32.     }
  33.  
  34.  
  35.     system("pause");
  36.     return true;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement