Commit 13c77715 authored by Dominik Charousset's avatar Dominik Charousset

tweaks for optional variant visitors

parent 0e8eabbd
...@@ -76,12 +76,15 @@ struct optional_variant_move_helper { ...@@ -76,12 +76,15 @@ struct optional_variant_move_helper {
T& lhs; T& lhs;
optional_variant_move_helper(T& lhs_ref) : lhs(lhs_ref) { } optional_variant_move_helper(T& lhs_ref) : lhs(lhs_ref) { }
template<typename U> template<typename U>
inline void operator()(const U& rhs) const { inline void operator()(U& rhs) const {
lhs = std::move(rhs); lhs = std::move(rhs);
} }
inline void operator()() const { inline void operator()() const {
lhs = unit; lhs = unit;
} }
inline void operator()(const none_t&) const {
lhs = none;
}
}; };
template<typename... Ts> template<typename... Ts>
...@@ -382,6 +385,8 @@ struct optional_variant_cmp_helper { ...@@ -382,6 +385,8 @@ struct optional_variant_cmp_helper {
operator()(const U&) const { return false; } operator()(const U&) const { return false; }
// variant is void // variant is void
bool operator()() const { return false; } bool operator()() const { return false; }
// variant is undefined
bool operator()(const none_t&) const { return false; }
}; };
} // namespace detail } // namespace detail
......
...@@ -28,13 +28,11 @@ struct int_visitor { ...@@ -28,13 +28,11 @@ struct int_visitor {
using dlimits = std::numeric_limits<double>; using dlimits = std::numeric_limits<double>;
struct double_visitor { struct double_visitor {
double operator()(none_t) const { return dlimits::signaling_NaN(); } double operator()(none_t) const { return dlimits::signaling_NaN(); }
double operator()(void) const { return dlimits::quiet_NaN(); } double operator()() const { return dlimits::quiet_NaN(); }
double operator()(int i) const { return i; } template<typename T>
double operator()(float f) const { return f; } double operator()(T value) const { return value; }
double operator()(double d) const { return d; }
}; };
int main() { int main() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment