
axter wrote:
"Thorsten Ottosen" <tottosen@dezide.com> wrote in message news:<dpf7ec$9kl$1@sea.gmane.org>...
I just tested it again, and again it fails to compile. I even went through the trouble of taking out all the compiler directives, and cleaning the code so-as to remove any possible noise, but it still fails to compile.
I get the above error from the following four lines of code: boost::ptr_map<int, Shape> mIntToShape; int i123 = 123; mIntToShape.insert(i123, new Circle("blue")); mIntToShape[i123].draw(); //This line is what causes the error
operator[]() has special requirements in that it inserts a default constructed element. This implies T must be default constructible. It also implies that T cannot be abstract. I guess the docs could be better here. If you just want to do lookup, call mIntToShape.at(i123).draw(); -Thorsten