Boost logo

Boost Users :

Subject: Re: [Boost-users] serialization: BOOST_STATIC_WARNING
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2011-05-25 15:16:04


On Wed, May 25, 2011 at 7:09 PM, Travis Gockel <travis_at_[hidden]> wrote:

> I've recently had some trouble with C++'s implicit casting, so I'm looking
> for a way to warn people if somebody attempts to assign an int32_t to a
> uint64_t or whatever. BOOST_STATIC_ASSERT would work wonders for this,
> except that the code base I'm working with is quite large and relies on a
> lot of implicit casting, so immediately breaking everything with assertions
> is unrealistic.
>
> It looks like BOOST_STATIC_WARNING (
> http://www.boost.org/doc/libs/1_46_1/libs/serialization/doc/static_warning.html)
> would be ideal for me, however, I cannot get it to actually emit a warning.
> I have attached a quick example of what I am looking for, but it
> essentially boils down to this not doing anything:
>
> typedef boost::is_same<int64_t, int32_t> same_type;
> BOOST_STATIC_WARNING(same_type::value);
>
> My compiler is g++ 4.4.3 with --std=c++0x -Wall -Wextra.
>
> Thanks!
>

Hello Travis,

unfortunately I have no boost 1.46 by the hand, but as far as I understand
int64_t and int32_t are different type and should not result in value equals
true. What happens if you produce non-convertible types like:

template<class T> identity{}; //you can also use mpl::identity

typedef boost::is_same<identity<int64_t>, identity<int32_t> > same_type;

BOOST_STATIC_WARNING(same_type::value);

With Kind 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