Commit 140d6d28 authored by Dominik Charousset's avatar Dominik Charousset

Fix build on MSVC

parent 16cc8501
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "caf/variant.hpp" #include "caf/variant.hpp"
#include "caf/detail/arg_wrapper.hpp" #include "caf/detail/arg_wrapper.hpp"
#include "caf/detail/type_traits.hpp"
namespace caf { namespace caf {
namespace test { namespace test {
...@@ -127,29 +128,36 @@ struct inequality_operator { ...@@ -127,29 +128,36 @@ struct inequality_operator {
}; };
template <class Operator> template <class Operator>
struct comparison { class comparison {
public:
// -- default case ----------------------------------------------------------- // -- default case -----------------------------------------------------------
template <class T, class U> template <class T, class U>
detail::enable_if_t<!SumType<T>() && !SumType<U>(), bool> bool operator()(const T& x, const U& y) const {
operator()(const T& x, const U& y) { std::integral_constant<bool, SumType<T>()> lhs_is_sum_type;
Operator f; std::integral_constant<bool, SumType<U>()> rhs_is_sum_type;
return f(x, y); return cmp(x, y, lhs_is_sum_type, rhs_is_sum_type);
} }
private:
// -- automagic unboxing of sum types ---------------------------------------- // -- automagic unboxing of sum types ----------------------------------------
template <class T, class U> template <class T, class U>
detail::enable_if_t<SumType<T>(), bool> bool cmp(const T& x, const U& y, std::false_type, std::false_type) const {
operator()(const T& lhs, const U& rhs) const { Operator f;
compare_visitor<U, comparison> f{rhs}; return f(x, y);
return visit(f, lhs); }
template <class T, class U>
bool cmp(const T& x, const U& y, std::true_type, bool) const {
compare_visitor<U, comparison> f{y};
return visit(f, x);
} }
template <class T, class U> template <class T, class U>
detail::enable_if_t<!SumType<T>() && SumType<U>(), bool> bool cmp(const T& x, const U& y, std::false_type, std::true_type) const {
operator()(const T& lhs, const U& rhs) const { compare_visitor<T, comparison> f{x};
return (*this)(rhs, lhs); return visit(f, y);
} }
}; };
......
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