Boost logo

Boost Users :

Subject: Re: [Boost-users] using boost::is_same with enums
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2011-05-27 06:03:44


On Fri, May 27, 2011 at 11:52 AM, Ovanes Markarian
<om_boost_at_[hidden]>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



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