boost::hof::is_invocable is always creating std::true_type causing this code to not to compile:
#include <boost/variant.hpp>
#include <string>
#include <set>
#include <type_traits>
#include <boost/hof/is_invocable.hpp>
struct direct
{
};
template<typename T>
struct CDep
{ template<typename T1>
CDep operator-(const CDep<T1>&) const
{ static_assert(
!std::is_same<T, std::string>::value
&& !std::is_same<T1, std::string>::value,
"must not be a string!"
);
return {};
}
};
typedef boost::variant<
CDep<double>,
CDep<int>,
CDep<std::string>
> values;
template<typename T0>
struct second
{ const T0&m_r;
second(const T0&_r)
:m_r(_r)
{
}
template<typename T>
values operator()(const T&_r1)
{ return m_r - _r1;
}
template<typename T>
values operator()(const T&_r1, const std::true_type&) const
{ return (*this)(_r1);
}
template<typename T>
values operator()(const T&, const std::false_type&) const
{ throw std::logic_error("does not compile!");
}
template<typename T>
values operator()(const T&_r0) const
{ return (*this)(
_r0,
std::integral_constant<
bool,
(boost::hof::is_invocable<second<T0>, T>())
>()
);
}
};
struct first
{ const values&m_r;
first(const values&_r)
:m_r(_r)
{
}
template<typename T>
values operator()(const T&_r0) const
{ return boost::apply_visitor(second<T>(_r0), m_r);
}
};
values operator-(const values&_r0, const values&_r1)
{ return boost::apply_visitor(first(_r1), _r0);
}
int main(int, char**)
{ values(CDep<int>()) - values(CDep<int>());
values(CDep<std::string>()) - values(CDep<std::string>());
}
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.