Open mika-fischer opened 6 years ago
The following works for me in container_traits
in stl_bind.h
:
template <typename T2> static decltype(std::declval<const T2 &>() == std::declval<const T2 &>()) test_comparable(decltype(std::declval<const T2 &>() == std::declval<const T2 &>())*);
template <typename T2> static void test_comparable(...);
static constexpr const bool is_comparable = std::is_convertible<decltype(test_comparable<T>(nullptr)), bool>::value;
Issue description
When a type has
operator==
defined, but it returns something other thanbool
or something that can be converted tobool
, the detection logic incontainer_traits<T>::test_comparable
fails and returnstrue
when it should returnfalse
. Then code gets instantiated invector_if_equal_operator
which then fails to compile.It should additionally to the existence of
operator==
be checked whether the return value can be converted tobool
. But my metaprogramming skills are not good enough to come up with a clean solution...Reproducible example code
The actual type for which I ran into this is
cv::Mat
from OpenCV. And I worked around it for now with: