I have a problem on Solaris using the Sun Studio compiler, which is most likely due to the strange STL implementation (libCstd) used, see http://developers.sun.com/solaris/articles/cmp_stlport_libCstd.html. Consider this:
std::vector<C*> v;
// .. populate the vector
std::sort(v.begin(), v.end());
where C
is some class. This produces the following compiler error message:
"/opt/sunstudio12.1/prod/include/CC/Cstd/./algorithm", line 725: Error: The operand "*first" cannot be assigned to.
"/opt/sunstudio12.1/prod/include/CC/Cstd/./algorithm.cc", line 985: Where: While instantiating "std::__linear_insert<C*const*, C*>(C*const*, C*const*, C**)".
"/opt/sunstudio12.1/prod/include/CC/Cstd/./algorithm.cc", line 985: Where: Instantiated from std::__insertion_sort<C*const*>(C*const*, C*const*).
"/opt/sunstudio12.1/prod/include/CC/Cstd/./algorithm", line 811: Where: Instantiated from non-template code.
Does anybody know how to circumvent the problem? Of course, actually I want to use std::sort
with a custom comparison functor, but even this simple version does not work.
Looks like your actual vector is const. Is it a member variable accessed in a const member function? Is it a const function argument?