Boost logo

Boost Users :

Subject: [Boost-users] using boost::is_same with enums
From: przemyslaw.sliwa_at_[hidden]
Date: 2011-05-27 05:22:24


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-845C5H for additional disclosures.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net