I have a class which represents a decomposed URL.
class URL
{
std::string proto_;
std::string host_;
/* other fields */
};
(for example, proto_
can be http, https, ldap; host_
can be localhost:1234, google.com).
The real, meaningful value to be compared is of course the composed URL. But constructing it is expensive and I'd like to use this class a key-type for a std::map
.
How can I implement a operator<()
for this class in an efficient way? How to combine the comparison of distinct objects, which are in fact forming a whole, logically?
I tried using std::tie
but the results are not as I expected.
Aucun commentaire:
Enregistrer un commentaire