Have you ever find yourself reinventing the wheel by implementing readily available algorithms, containers or other library components? What were your motives? Was it worth the trouble? Tell us about it in the c++.general discussion group.
Though the Standard Template Library offers a generic swap() algorithm, there are several other implementations from which to choose. Which implementation best suits your program's needs? This month's solution shows you how to evaluate each of them, enabling you to utilize each implementation to its greatest benefit.
by Danny Kalev, C++ Pro
March 12, 2003
wap() is one of those tricky algorithms that has several implementations, each of which offers its own advantages and disadvantages. In the following sections I will show why familiarity with these implementations may be beneficial, albeit for different reasons than you might think.
The Standard Template Library offers a ready-made generic swap() algorithm (in the form of std::swap() which is defined in <algorithm>). Still, there are several other implementations of this algorithm. How do you choose which implementation to use? On which criteria should your evaluation be based?
It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com. Already a member?
To become a member of DevX.com create your Member Profile by completing the form below. Membership is free!