Boost logo

Boost Users :

From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2005-04-04 13:29:26


> Date: Mon, 04 Apr 2005 16:39:34 +0100
> From: Ben Hutchings <ben.hutchings_at_[hidden]>
> Subject: Re: [Boost-users] Re: unordered_map has no lower_bound?
> To: boost-users_at_[hidden]
> Message-ID: <42515FB6.9040803_at_[hidden]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Daniel James wrote:
> >> Martin Wartens wrote:
> >>
> >>> PS: there is a small problem in hash_table.hpp causing a warning in
> >>> VC7.1
> >>> line 278 should be:
> >>> return (*prev_ptr)!=0;
> >>> instead of
> >>> return *prev_ptr;
> >
> >
> > Ah, I just found out why I didn't do this before - prev_ptr might be a
> > pointer object (depending on the allocator), so the correct line is:
> >
> > return (*prev_ptr) != link_ptr();
> >
> > Which can potentially be inefficient. I think the best thing to do is to
> > use a pragma to disable the warning,
>
> If it's the warning I'm thinking of (C4800: "forcing value to bool
> 'true' or 'false'" - well, *duh*) then this is the right approach.
>
> > or maybe:
> >
> > return static_cast<bool>(*prev_ptr);
> >
> > or:
> >
> > return boost::implicit_cast<bool>(*prev_ptr);
> >
> > would work.
>
> Neither of those prevents the warning.
>
> Ben.
>

I always use !! to prevent that warning. like

   return !!*prev_ptr;

YMMV.


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