c++ - Why is there no std::is_transparent equivalent for unordered containers? -
c++14 introduces compare::is_transparent
equivalent find operations in associative containers.
template< class k > iterator find( const k& x ); template< class k > const_iterator find( const k& x ) const;
finds element key compares equivalent value x. overload participates in overload resolution if qualified-id compare::is_transparent valid , denotes type. allows calling function without constructing instance of key
since there no longer temporary instance of key
constructed, these can more efficient.
there not seem equivalent unordered containers.
why there no compare::key_equal
/ compare::hash_equal
?
i imagine relatively simple allow efficiently looking of, eg, string literals in unordered containers?
template<> struct hash<string> { std::size_t operator()(const string& s) const { return ...; } // hash_equal=true allows hashing string literals std::size_t operator()(const char* s) const { return ...; } };
if watch grill committee video cppcon, explain why stuff happens: nobody fought it.
c++ standardized committee committee requires input community. has write papers, respond criticism, go meetings, etc... feature can voted on. committee doesn't sit there inventing language , library features. discusses , votes on brought forward it.
Comments
Post a Comment