using boost::is_same with enums

Hello, I am trying to use boost::is_same in the folloting case enum eOperation { ePlus = 0, eMinus, eMult, eDivide }; template<eOperation P, eOperation Q> boost::shared_ptr<std::vector<intervalPtr> > convertIntervals() const { BOOST_STATIC_ASSERT( (boost::is_same<P, eDivide>::value && boost::is_same<Q, eMinus>::value) || (boost::is_same<P, eMult>::value && boost::is_same<Q, ePlus>::value)); static const double dNoOfSecsInADay(3600*24); boost::shared_ptr<std::vector<intervalPtr> > out(new std::vector<intervalPtr>(m_intervals.size())); // more code here return out; } Could someone help me with this? it does not compile at all on VC++2010. The error i get is 1>Pshemek -> this needs to be improved, no constructor calls at all when merged back to HEAD 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2974: 'boost::is_same' : invalid template argument for 'T', type expected 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1> d:\dev\13_1x\development\cpp\market\event.cpp(689) : see reference to function template instantiation 'boost::shared_ptr<T> SohoEvents::StandardDayEvent::convertIntervals<eDivide,eMinus>(void) const' being compiled 1> with 1> [ 1> T=std::vector<SohoEvents::intervalPtr> 1> ] 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2974: 'boost::is_same' : invalid template argument for 'U', type expected 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2955: 'boost::is_same' : use of class template requires template argument list 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2974: 'boost::is_same' : invalid template argument for 'T', type expected 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2974: 'boost::is_same' : invalid template argument for 'U', type expected 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2955: 'boost::is_same' : use of class template requires template argument list 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2974: 'boost::is_same' : invalid template argument for 'T', type expected 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2974: 'boost::is_same' : invalid template argument for 'U', type expected 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2955: 'boost::is_same' : use of class template requires template argument list 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2974: 'boost::is_same' : invalid template argument for 'T', type expected 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2974: 'boost::is_same' : invalid template argument for 'U', type expected 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2955: 'boost::is_same' : use of class template requires template argument list 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>' 1> with 1> [ 1> x=false 1> ] 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2974: 'boost::is_same' : invalid template argument for 'T', type expected 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1> d:\dev\13_1x\development\cpp\market\event.cpp(713) : see reference to function template instantiation 'boost::shared_ptr<T> SohoEvents::StandardDayEvent::convertIntervals<eMult,ePlus>(void) const' being compiled 1> with 1> [ 1> T=std::vector<SohoEvents::intervalPtr> 1> ] 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2974: 'boost::is_same' : invalid template argument for 'U', type expected 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2955: 'boost::is_same' : use of class template requires template argument list 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2974: 'boost::is_same' : invalid template argument for 'T', type expected 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2974: 'boost::is_same' : invalid template argument for 'U', type expected 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2955: 'boost::is_same' : use of class template requires template argument list 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2974: 'boost::is_same' : invalid template argument for 'T', type expected 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2974: 'boost::is_same' : invalid template argument for 'U', type expected 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2955: 'boost::is_same' : use of class template requires template argument list 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2974: 'boost::is_same' : invalid template argument for 'T', type expected 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2974: 'boost::is_same' : invalid template argument for 'U', type expected 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2955: 'boost::is_same' : use of class template requires template argument list 1> d:\dev\13_1x\thirdparty\boost\type_traits\is_same.hpp(37) : see declaration of 'boost::is_same' 1>d:\dev\13_1x\development\cpp\market\event.cpp(668) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>' 1> with 1> [ 1> x=false 1> ] 1>Build log was saved at "file://d:\Dev\13_1X\Development\CPP\market\Debug\BuildLog.htm" 1>Market - 26 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== ___________________________________________________________ This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is prohibited. Please refer to http://www.bnpparibas.co.uk/en/information/legal_information.asp?Code=ECAS-8... for additional disclosures.

Hi! Sorry for top-post but my mailer does not correctly reproduce the initial email in the reply. Why do you need boost::is_same in this context at all, if you can compare the values directly???? This should work: BOOST_STATIC_ASSERT((P==eDivide && Q==eMinus) || (P==eMult && Q==ePlus)); With Kind Regards, Ovanes On Fri, May 27, 2011 at 11:22 AM, <przemyslaw.sliwa@uk.bnpparibas.com>wrote:
*[...]*

On Fri, May 27, 2011 at 11:52 AM, Ovanes Markarian <om_boost@keywallet.com>wrote:
Hi!
Sorry for top-post but my mailer does not correctly reproduce the initial email in the reply.
Why do you need boost::is_same in this context at all, if you can compare the values directly????
This should work: BOOST_STATIC_ASSERT((P==eDivide && Q==eMinus) || (P==eMult && Q==ePlus));
With Kind Regards, Ovanes
Just a small addition (explanation): is_same operates on types, but you pass constants. If are still willing to use is_same, than make types out of constants: boost::is_same<boost::mpl::int_<P>, boost::mpl::int_<eDivide> >::value && ... This should work as well, but is overkill, since you don't need this machinery here ;) Regards, Ovanes
participants (2)
-
Ovanes Markarian
-
przemyslaw.sliwa@uk.bnpparibas.com