![]() |
| | #16 | |
| The larch Join Date: May 2006
Posts: 3,082
| While I very much appreciate the power of C++ algorithms, they are very generic which means that if you read the code, it may not be quite obvious what it is supposed to achieve. For this reason I tend to wrap even single calls to some algorithm in a separate function (where I unleash all the powers of boost function objects )
__________________ I might be wrong. Quote:
| |
| anon is offline | |
| | #17 |
| C++0x User Join Date: Nov 2008 Location: Sweden
Posts: 133
| std::adjacent_find does its job :P |
| Tux0r is offline | |
| | #18 | |
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,352
| Quote:
If you can come up with a name that is more descriptive than all (like all_equal, I suppose), then by implementing a function template you enhance the readability of your code and actually reduce the "reinvention of the wheel" since you now can apply your generic algorithm instead of implementing what you want to do using a more generic algorithm every time you want to do it. In the case of an array, you might even save on an unnecessary computation of a one past the end pointer (though compiler optimisation may well do that for you anyway), since the use of adjacent_find in this case uses a one past the end iterator twice.
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way | |
| laserlight is offline | |
![]() |
| Tags |
| class, operator== |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| stl error | eklavya8 | C++ Programming | 8 | 06-30-2008 12:01 PM |
| "error: incomplete type is not allowed" | Fahrenheit | C++ Programming | 9 | 05-10-2005 09:52 PM |
| Problem with Template Function and overloaded equality operator | silk.odyssey | C++ Programming | 7 | 06-08-2004 04:30 AM |
| operator== | Unregistered | C++ Programming | 4 | 03-26-2002 05:24 PM |