stdmap - Map lookup using boost::tuple as key -
i understand how key in form of boost::tuple looked in map, compare=std::less
. instance, snippet of code i'm working on:
typedef boost::tuple<std::string, std::string> key; void *data; typedef std::map<key, data> filedatamap; filedatamap file_map; lookup_data(std::string s1, std::string s2) { ... fk = boost::make_tuple(s1, s2); filedatamap::iterator itr = file_map.find(fk); ... ... } insert_data(std::string s1, std::string s2, void *fdata) { ... fk = boost::make_tuple(s1, s2); file_map.insert(std::make_pair(fk, fdata)); ... ... }
at time of inserting value map, let's suppose s1
abc
, s2
xyz
. during lookup, how key match determined?
is string comparison of s1
, s2
done abc
, xyz
respectively, individually? if so, std::string
comparison operators used?
thanks!
i wrote code test out. testing indicates strings indeed compared individually using defined comparison operators.
the document talks on similar lines: http://en.cppreference.com/w/cpp/utility/tuple/operator_cmp
Comments
Post a Comment