c++ template class; function with arbitrary container type, how to define it?
Traits solution. Generalize not more than needed, and not less. In some cases that solution might not be enough as it will match any template with such signature (e.g. shared_ptr), in which case you could make use of type_traits, very much like duck-typing (templates are duck typed in general). #include <type_traits> // Helper to determine … Read more