From Jason Turner
Watch on YouTube

Summary

This episode explores transparent comparators, a C++14 feature that enables more efficient lookups in associative containers like std::set and std::map. Jason demonstrates how traditional comparators force the creation of temporary objects when searching by just a key value, while transparent comparators allow direct comparison with different types. By adding the 'is_transparent' type alias and implementing templated comparison operators, containers can perform lookups without constructing unnecessary temporary objects, resulting in more efficient code.

Resources

Tags