diff options
Diffstat (limited to 'import/hwpf/fapi2/include/buffer_parameters.H')
-rw-r--r-- | import/hwpf/fapi2/include/buffer_parameters.H | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/import/hwpf/fapi2/include/buffer_parameters.H b/import/hwpf/fapi2/include/buffer_parameters.H index 3dc41b26..1ad9ba43 100644 --- a/import/hwpf/fapi2/include/buffer_parameters.H +++ b/import/hwpf/fapi2/include/buffer_parameters.H @@ -41,12 +41,17 @@ namespace fapi2 class parameterTraits { public: - enum - { - mask = T(~0), - bit_length = sizeof(T) * 8, - byte_length = sizeof(T), - }; + // Why constexpr functions? Enums are hard to do math on, and + // static const doesn't work without -O1 (or greater.) That might + // be a bug in g++ but this works just the same. + constexpr static uint32_t mask(void) + { return T(~0); } + + constexpr static uint32_t byte_length(void) + { return sizeof(T); } + + constexpr static uint32_t bit_length(void) + { return sizeof(T) * 8; } template<typename U> inline static void write_element(void* i_data, T i_value, uint32_t i_offset) @@ -60,6 +65,6 @@ namespace fapi2 } }; /// @endcond -}; +} #endif |