Boost::Container::Vector with Enum Template Argument - Not Legal Base Class
        Posted  
        
            by CuppM
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by CuppM
        
        
        
        Published on 2010-04-20T20:43:06Z
        Indexed on 
            2010/04/20
            21:03 UTC
        
        
        Read the original article
        Hit count: 333
        
Hi,
I'm using Visual Studio 2008 with the Boost v1.42.0 library.  If I use an enum as the template argument, I get a compile error when adding a value using push_back().  The compiler error is: 'T': is not a legal base class and the location of the error is move.hpp line 79.
#include <boost/interprocess/containers/vector.hpp>
class Test {
public:
 enum Types {
  Unknown = 0,
  First = 1,
  Second = 2,
  Third = 3
 };
 typedef boost::container::vector<Types> TypesVector;
};
int main() {
 Test::TypesVector o;
 o.push_back(Test::First);
 return 0;
}
If I use a std::vector instead it works.  And if I resize the Boost version first and then set the values using the [] operator it also works.
Is there some way to make this work using push_back()?
© Stack Overflow or respective owner