Signature de boost::bimap
Bonjour,
J'ai récemment écrit la fonction suivante :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| template <typename T>
bool isStringInMapKeys( std::string const &s, std::map<std::string,T> const &m ) {
/*
Cette fonction renvoie true si s est l'une des clés de m. Sinon, elle renvoie false.
*/
for ( typename std::map<std::string,T>::const_iterator it = m.begin() ; it != m.end() ; ++it ) {
if ( it->first == s ) return true;
}
return false;
} |
J'aimerais aussi pouvoir l'utiliser avec des boost::bimap<string, T>. J'ai lu dans la documentation de bimap :
Citation:
bm.left is signature-compatible with std::map<A,B>
Pourtant, lorsque je crée un objet boost::bimap<string,int> myBimap (par exemple) et que j'essaye d'appeler la fonction :
Code:
isStringInMapKeys("test",myBimap.left);
la compilation échoue en renvoyant le message suivant :
Citation:
error: no matching function for call to ‘isStringInMapKeys(const char [5], boost::bimaps::views::map_view<boost::bimaps::relation::member_at::right, boost::bimaps::detail::bimap_core<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, mpl_::na, mpl_::na, mpl_::na> >&)’
Aurais-je mal compris ce qu'implique l'identité des signatures de bimap.left et de map ?
Merci d'avance pour vos réponses !