I have an immutable class - all members are const. Since it's immutable, there is no default constructor and no copy assignment. In C++11 I use this class in an std::vector with no problems.
Now I need to compile the code in an environment that only supports C++03. Since my class is not CopyAssignable, and C++03 std::vector requires this, I can't put instances of the class in a vector.
Since the code will be maintained on C++11-friendly compilers, and only compile and run on a C++03 environment, I thought the easiest way to make this work was to remove the const modifier in C++03. This will make the class CopyAssignable and will work in C++03. In C++11 I still want the class to be immutable, of course.
I went over the long list of Boost C++11 Macros, but couldn't find one that will tell me if std::vector requires CopyAssignable types.
Is there a way to do that, or should I just introduce my own macro that will be set during compilation?
Aucun commentaire:
Enregistrer un commentaire