Skip to main content

New answers tagged

1vote

How to combine multiple functions into a single template based function

Sure, combine to reuse by splitting them: result = FindMaxDistanceList(obj1, obj2); if (_DEBUG_ENABLED_) PrintDebugInfo(obj1, ob2); This way, each call site gets to decide what to print, and ...
Basilevs's user avatar
2votes

How to combine multiple functions into a single template based function

In my experience, the easiest way to have a template that does specific things for one particular type is overloading. void PrintDebugInfo(std::list<int>& obj1, std::list<int>& ...
Sebastian Redl's user avatar
4votes

How to combine multiple functions into a single template based function

It is impossible for us to tell if there is a better way for merging such two similar but not identical functions without knowing the details of the actual functions and how the differences cam about. ...
Bart van Ingen Schenau's user avatar
0votes

How to combine multiple functions into a single template based function

In your case, both FindMaxDistanceVector and FindMaxDistanceList perform analogous operations on std::vector and std::list, respectively. By using iterators, your function can operate on any container ...
Square Root Solutions UK's user avatar

Top 50 recent answers are included

close