|
Is there a reason to prefer |
Replies: 2 comments
|
I find CppAD::vector easier to use than std::vector because it does error checking for the [] operator for indices out of range (when NDEBUG is not defined). It also does this for its iterators. In addition, the CppAD vector class is much easier to use in the debugger (simpler to view the data). Sometimes, I make it a configuration option to choose CppAD::vector or std::vector. There are other vector classes that do index error checking; e.g. Eigen's vector class |
|
Another thing I forgot to mention is that CppAD::vector using the multi-threading allocator Perhaps it would be interesting to test the speed of std::vector versus CppAD::vector for some multi-threading examples. |
I find CppAD::vector easier to use than std::vector because it does error checking for the [] operator for indices out of range (when NDEBUG is not defined). It also does this for its iterators. In addition, the CppAD vector class is much easier to use in the debugger (simpler to view the data). Sometimes, I make it a configuration option to choose CppAD::vector or std::vector.
There are other vector classes that do index error checking; e.g. Eigen's vector class
https://cppad.readthedocs.io/latest/cppad_eigen.hpp.html