4 ms·
const never really worked with other C++ features[0], so in any big pile of code you're better off not using const. [0] The compiler will gladly pass a non-con
by maratc 3y ago
const never really worked with other C++ features[0], so in any big pile of code you're better off not using const.
[0] The compiler will gladly pass a non-const pointer to a non-const object to a function that expects a const pointer to a const object; it all "makes sense". However, a compiler will explode when you're trying to pass a non-const vector of non-const objects to a function that expects a const vector of const objects.
- spacechild1 3y ago> a function that expects a const vector of const objects. The elements of std::vector cannot be const.