Moderator: Mods&Dev moderators
template <size_t N> struct type { };
#define DEFINE_TYPE(T) template <> struct type<sizeof(T)> { typedef T uint; }
DEFINE_TYPE(boost::uint8_t);
DEFINE_TYPE(boost::uint16_t);
DEFINE_TYPE(boost::uint32_t);
DEFINE_TYPE(boost::uint64_t);
#undef DEFINE_TYPE
// ReadUInt<boost::uint64_t> calls ReadUInt<boost::uint32_t> and ReadUInt<boost::uint32_t>
// ReadUInt<boost::uint32_t> calls ReadUInt<boost::uint16_t> and ReadUInt<boost::uint16_t>
// ReadUInt<boost::uint16_t> calls ReadUInt<boost::uint8_t> and ReadUInt<boost::uint8_t>
// ReadUInt<boost::uint8_t> reads single byte from the stream
//
// The result is then bitshifted and ORed to reconstruct the value.
template <typename T>
T ReadUInt(std::ifstream& stream) {
typedef type<sizeof(T) / 2>::uint smaller; //// Line 1167 - the ERROR
const boost::uint32_t smallerBits = sizeof(smaller) * 8;
smaller a, b;
a = ReadUInt<smaller>(stream);
b = ReadUInt<smaller>(stream);
return ((T)a << smallerBits) | (T)b;
}
typedef typename type<sizeof(T) / 2>::uint smaller;Return to Modding and Development
Users browsing this forum: No registered users and 1 guest