Synopsis: | Use functionality from the std library if possible |
Language: | C++ |
Severity Level: | 5 |
Category: | Parts of C++ to Avoid |
Description: |
It is better to use the standard library std if possible because it minimizes the number of external dependencies. For instance, since the introduction of C++11, a lot of Boost functionality is now available from the standard library std. Sometimes there is a one to one relation between std and Boost such as boost::bind that is replaced by std::bind. But sometimes this relation is less trivial, e.g. to make a class non-copyable one should derive from the boost::noncopyable class in the Boost case: class X : private boost::noncopyable {}; whereas in C++11 this is done differently by using "delete" for the constructor and copy constructor: class X { X(const X&) = delete; X& operator=(const X&) = delete; }; |