Hi Steven,
Thats kind of what I would like to have, I was wondering of something like
that using "enum class" for type_safety would work.
I will give it a try and see how it goes.
Thanks for the comment.
Damian
2018-07-27 14:38 GMT-04:00 Steven Watanabe via Boost
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
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/ mailman/listinfo.cgi/boost