(svn r19616) -Codechange: Increase transparency of 'Extract' by passing also the number of used bits.

This commit is contained in:
frosch
2010-04-13 17:29:19 +00:00
parent 7ba4f98ce5
commit b76f0185d4
5 changed files with 12 additions and 11 deletions

View File

@@ -14,12 +14,13 @@
#include "core/enum_type.hpp"
template<typename T, uint N, typename U> static inline T Extract(U v)
template<typename T, uint S, uint N, typename U> static inline T Extract(U v)
{
/* Check if there are enough bits in v */
assert_tcompile(N + EnumPropsT<T>::num_bits <= sizeof(U) * 8);
assert_tcompile(EnumPropsT<T>::end <= (1 << EnumPropsT<T>::num_bits));
return (T)GB(v, N, EnumPropsT<T>::num_bits);
assert_tcompile(N == EnumPropsT<T>::num_bits);
assert_tcompile(S + N <= sizeof(U) * 8);
assert_tcompile(EnumPropsT<T>::end <= (1 << N));
return (T)GB(v, S, N);
}
#endif