samedi 18 juin 2016

Compile TIme Error While using Unordered_map in C++ [duplicate]


This question already has an answer here:

Umm , For some issue , I need to use unordered_map< pair ,bool > mm;

But when i try to compile it I m getting issues

#include<bits/stdc++.h>
using namespace std;

int main()
{
    unordered_map< pair<int,int> ,bool > ump; -> here the program doesn't compile and execute
    ump[make_pair(4,5)]=true; 
}

And the Compile errors I obtained are :--

In file included from /usr/include/c++/5/bits/hashtable.h:35:0,
             from /usr/include/c++/5/unordered_map:47,
             from /usr/include/i386-linux-gnu/c++/5/bits/stdc++.h:115,
             from prog.cpp:1:
/usr/include/c++/5/bits/hashtable_policy.h: In instantiation of 'struct    
std::__detail::__is_noexcept_hash<std::pair<int, int>,    
std::hash<std::pair<int, int> > >':
/usr/include/c++/5/type_traits:137:12:   required from 'struct std   
::__and_<std::__is_fast_hash<std::hash<std::pair<int, int> > >,    
std::__detail::__is_noexcept_hash<std::pair<int, int>,  
std::hash<std::pair<int, int> > > >' /usr/include/c++/5/type_traits:148:38required from'structstd::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int,int> > >, std::__detail::__is_noexcept_hash<std::pair<int, int>,std::hash<std::pair<int, int> > > > >'/usr/include/c++/5/bits/unordered_map.h:100:66:   required from'classstd::unordered_map<std::pair<int, int>, bool>'prog.cpp:47:45: required from here /usr/include/c++/5/bits/hashtable_policy.h:85:34: error: no match for call to '(const std::hash<std::pair<int, int> >) (const std::pair<int, int>&)'
noexcept(declval<const _Hash&>()(declval<const _Key&>()))>
                              ^
In file included from /usr/include/c++/5/bits/move.h:57:0,
             from /usr/include/c++/5/bits/stl_pair.h:59,
             from /usr/include/c++/5/bits/stl_algobase.h:64,
             from /usr/include/c++/5/bits/char_traits.h:39,
             from /usr/include/c++/5/ios:40,
             from /usr/include/c++/5/istream:38,
             from /usr/include/c++/5/sstream:38,
             from /usr/include/c++/5/complex:45,
             from /usr/include/c++/5/ccomplex:38,
             from /usr/include/i386-linux-gnu/c++/5/bits/stdc++.h:52,
             from prog.cpp:1:
    /usr/include/c++/5/type_traits: In instantiation of 'struct      
    std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int,                  
    int> > >, std::__detail::__is_noexcept_hash<std::pair<int, int>,                    
    std::hash<std::pair<int, int> > > > >':
    /usr/include/c++/5/bits/unordered_map.h:100:66:   required from 'class    
    std::unordered_map<std::pair<int, int>, bool>'
    prog.cpp:47:45:   required from here
   /usr/include/c++/5/type_traits:148:38: error: 'value' is not a member of 
   'std::__and_<std::__is_fast_hash<std::hash<std::pair<int, int> > >,   
   std::__detail::__is_noexcept_hash<std::pair<int, int>,    
   std::hash<std::pair<int, int> > > >'
   : public integral_constant<bool, !_Pp::value>
                                  ^ 
   In file included from /usr/include/c++/5/unordered_map:48:0,
             from /usr/include/i386-linux-gnu/c++/5/bits/stdc++.h:115,
             from prog.cpp:1:
   /usr/include/c++/5/bits/unordered_map.h: In instantiation of 'class        
   std::unordered_map<std::pair<int, int>, bool>': 
   prog.cpp:47:45:   required from here
  /usr/include/c++/5/bits/unordered_map.h:100:66: error: 'value' is not a         member of   

  std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, int>  
  > >, std::__detail::__is_noexcept_hash<std::pair<int, int>,   
  std::hash<std::pair<int, int> > > > >'
   typedef __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc>  _Hashtable;
                                                              ^
  /usr/include/c++/5/bits/unordered_map.h:107:45: error: 'value' is not a    
  member of '   
  std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, int >    
  > >, std::__detail::__is_noexcept_hash<std::pair<int, int>,   
  std::hash<std::pair<int, int> > > > >'
   typedef typename _Hashtable::key_type key_type;
                                         ^
  /usr/include/c++/5/bits/unordered_map.h:108:47: error: 'value' is not a   
  member of   
 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, int>          
 > >,  std::__detail::__is_noexcept_hash<std::pair<int, int>,    
 std::hash<std::pair<int, int> > > > >'
   typedef typename _Hashtable::value_type value_type;
                                           ^
 /usr/include/c++/5/bits/unordered_map.h:109:48: error: 'value' is not a    
 member of    
 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, int>    
 > >, std::__detail::__is_noexcept_hash<std::pair<int, int>,   
 std::hash<std::pair<int, int> > > > >'
   typedef typename _Hashtable::mapped_type mapped_type;
                                            ^
 /usr/include/c++/5/bits/unordered_map.h:110:43: error: 'value' is not a   
  member of    
    'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int,   
 int>   
 > >, std::__detail::__is_noexcept_hash<std::pair<int, int>,   
 std::hash<std::pair<int, int> > > > >'
   typedef typename _Hashtable::hasher hasher;
                                       ^
/usr/include/c++/5/bits/unordered_map.h:111:46: error: 'value' is not a    
 member of    
 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, int>     
 >    
 >, std::__detail::__is_noexcept_hash<std::pair<int, int>,    
std::hash<std::pair<int, int> > > > >'
   typedef typename _Hashtable::key_equal key_equal;
                                          ^
/usr/include/c++/5/bits/unordered_map.h:112:51: error: 'value' is not a m    
ember of   
 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, int>   
>       
>, std::__detail::__is_noexcept_hash<std::pair<int, int>,   
std::hash<std::pair<int, int> > > > >'
   typedef typename _Hashtable::allocator_type allocator_type;
                                               ^
/usr/include/c++/5/bits/unordered_map.h:117:45: error: 'value' is not a    
 member of   
'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, int> >   
>, std::__detail::__is_noexcept_hash<std::pair<int, int>,  
std::hash<std::pair<int, int> > > > >'
   typedef typename _Hashtable::pointer  pointer;
                                         ^
/usr/include/c++/5/bits/unordered_map.h:118:50: error: 'value' is not a   
member of  
'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, int> >   
>, std::__detail::__is_noexcept_hash<std::pair<int, int>, 
std::hash<std::pair<int, int> > > > >'
   typedef typename _Hashtable::const_pointer const_pointer;
                                              ^
/usr/include/c++/5/bits/unordered_map.h:119:47: error: 'value' is not a 

I dont need any external links .. Any kind of help is appreciated if it is explained here. and Im thankful to them .. Iam new to c++ ..


Aucun commentaire:

Enregistrer un commentaire