Boost logo

Boost Users :

Subject: [Boost-users] using boost::is_same with enums
From: ÇÇ־ǿ (qiaozhiqiang_at_[hidden])
Date: 2011-05-27 06:07:52


template <class T, class U>
struct is_same : public true_type-or-false_type {};

'boost::is_same' : invalid template argument for 'T', type expected
is_same need type, not const value.

You can use:
BOOST_STATIC_ASSERT((P == eDivide && Q == eMinus) ||
                    (P == eMult && Q == ePlus));

> Message: 4
> Date: Fri, 27 May 2011 10:22:24 +0100
> From: przemyslaw.sliwa_at_[hidden]
> To: boost-users_at_[hidden]
> Subject: [Boost-users] using boost::is_same with enums
> Message-ID:
> <OF533BB172.765E47C7-ON8025789D.00332EF1-8025789D.00337D99_at_bnpparibas
> .com>
>
> Content-Type: text/plain; charset="us-ascii"
>
> 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.
> -------------- next part --------------
> HTML attachment scrubbed and removed
>
> ------------------------------
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
> End of Boost-users Digest, Vol 2735, Issue 1
> ********************************************


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