Quote Originally Posted by kempofighter View Post
You are right - I didn't think that one through well enough. It is impossible for default assignment to work for classes with const attributes. I duplicated your problem with a user defined struct type so I understand now. That is a really interesting issue. For any class with non-static, const members you couldn't always use that type with STL sequence containers. The concept of assignment doesn't make sense for that case since after the assignment the two classes could never be equal. So I guess in your case, why does the pair have to be const for T1? I have never run across this problem in any of my designs. In my experience I have always had situations where a class with constants either has a) static constants for all objects b) non-static constants but the class is a singleton type or c) used enum type for declaring sets of constants. With an enum decl within a class the class you don't have to instantiate the enum to use the constants and the values are the same for all class instances so it is similar to having static constants.
In my case, the vector's element type is map<T, U>::value_type which happens to be pair<const T, U>. There are good reasons why map<T, U> uses pair<const T, U> instead of pair<T, U> as its value type (the keys determine the ordering of the elements, so if you were allowed to change the key, the ordering could change without the map knowing it), but in this case it's really annoying because I can't store its value type in a vector.

My workaround in this case is to store pair<T, U> in the vector, but now I have to do an extra copy when I call map's insert() method because map's insert() method takes a pair<const T, U>& parameter, and so a temporary pair<const T, U> object has to be constructed from the pair<T, U> that's in the vector.