raw.hpp: Require high bits to be 0 when unpacking bool

This commit is contained in:
theoreticalbts 2015-10-12 09:02:45 -04:00
parent 6495004302
commit 1e10d3dc47

View file

@ -236,7 +236,13 @@ namespace fc {
// bool
template<typename Stream> inline void pack( Stream& s, const bool& v ) { pack( s, uint8_t(v) ); }
template<typename Stream> inline void unpack( Stream& s, bool& v ) { uint8_t b; unpack( s, b ); v=(b!=0); }
template<typename Stream> inline void unpack( Stream& s, bool& v )
{
uint8_t b;
unpack( s, b );
FC_ASSERT( (b & ~1) == 0 );
v=(b!=0);
}
namespace detail {