This commit is contained in:
Baptiste Wicht 2016-09-13 19:16:01 +02:00
parent 7dddb8d2d2
commit 223f40820a

View File

@ -22,8 +22,10 @@ struct bit_field {
return (*value >> Position) & ((1ULL << Size) - 1); return (*value >> Position) & ((1ULL << Size) - 1);
} }
bit_field& operator=(T new_value){ bit_field& operator=(T new_value_real){
S mask = ((1ULL << Size) - 1) << Position; S new_value(new_value_real);
size_t mask = ((S(1) << Size) - 1) << Position;
*value = (*value & ~mask) | ((new_value << Position) & mask); *value = (*value & ~mask) | ((new_value << Position) & mask);
return *this; return *this;
} }