AMDG On 07/26/2018 09:25 PM, Damian Vicino via Boost wrote:
I'm working in simplifying safe_float to prepare it for future review.
For now I'm focusing in a C++17 compatible version.
Currently safefloat receives 2 template parameters:
template
class safe_float ... Where FP is the floating point value being made "safe", float, double, long double ... and P is a Policy of what to check and how to react.
<snip> These are the options I'm considering
1) define typenames for each flag and assign them tuple of affected operations
class addition; <snip>
template<typename R> struct policy_x { using reporter=R; using overflow=tuple<addition>; <snip> };
2) define typename by operation, passing class with constexprs of flags being evaluated
struct empty_check{ static constexpr bool check_overflow=false; <snip> };
<snip>
3) similar to 2, but using true_type, and false_type in place of constexpr variables. <snip> 4) other options?
What about doing this the old-fashioned way: constexpr check_policy_t empty_check = 0; constexpr check_policy_t check_underflow = 0x1; constexpr check_policy_t check_overflow = 0x2; ... // with a bit of syntactic sugar: struct operation_id { check_policy_t offset; constexpr check_policy_t operator=(check_policy_t value) const { return offset * value; } }; constexpr operation_id addition=0x1, subtraction=0x100, multiplication=0x10000 ...; // Usage: addition=check_overflow|subtraction=empty_check In Christ, Steven Watanabe