New answers tagged coding-style
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 ...
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>& ...
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. ...
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 ...
Top 50 recent answers are included
Related Tags
coding-style × 1064coding-standards × 151
java × 106
c++ × 100
code-quality × 95
python × 76
programming-practices × 76
c# × 73
clean-code × 72
design × 55
c × 53
object-oriented × 46
naming × 46
javascript × 45
readability × 39
design-patterns × 27
php × 27
language-agnostic × 24
comments × 22
refactoring × 19
code-reviews × 19
conditions × 19
architecture × 18
exceptions × 17
functions × 17