Does any C++ standard guarantee that STL iterators can be stored in a union? If so, which standard?
For example:
union MyUnion {
std::vector<int>::iterator iter;
size_t size;
};
The reason that I ask is that I'm porting someone else's code that stores std::vector
and std::map
iterators in unions, and MSVC2013 doesn't seem to like it. I'm getting error C2621: illegal union member; type ... has a copy constructor. I would like to determine whether this is a bug in the code, a bug in the MS STL implementation, or a bug in my compiler.
Many thanks!