I am using boost 1.45.0 and have some code that does the following:
template <typename T = some_type, std::size_t N = 3> class my_class { public: typedef T value_type; ... ... my_class(value_type i0) {BOOST_STATIC_ASSERT(N==1); m_data[0]=i0;} protected: T m_data[N]; //!< The internal data array used to store indices } This generates the following error on MS VC++ 2010 (which I understand has implemented static_assert as one of their major changes) and no errors on MS VC++ 2008:
error C2338: N==1 Likewise, there are other errors at some other BOOST_STATIC_ASSERTs in the same code (left out for brevity).
I also tried replacing with the static_assert from VC++ but get a similar build error (prints out the message string).
What workaround exists for this?
functhat should trigger the error?Ndoesn't equal 1, so what do you expect?static_assertfails when the condition is false, not when it is true. Maybe that's where your confusion comes from? Just to be clear,3==1is false, hence it fails.