Skip to content
Snippets Groups Projects
Verified Commit 407861cd authored by Justin Carpentier's avatar Justin Carpentier
Browse files

core: add has_operator_equal helper

parent 703a6fb7
No related branches found
No related tags found
No related merge requests found
Pipeline #35415 passed with warnings
/*
* Copyright 2014-2023 CNRS INRIA
* Copyright 2014-2024 CNRS INRIA
*/
#ifndef __eigenpy_fwd_hpp__
......@@ -73,6 +73,9 @@
#include <boost/python.hpp>
#include <boost/python/scope.hpp>
#include <type_traits>
#include <utility>
namespace eigenpy {
namespace bp = boost::python;
......@@ -167,6 +170,22 @@ struct get_eigen_ref_plain_type<Eigen::TensorRef<TensorType> > {
typedef TensorType type;
};
#endif
namespace internal {
template <class T1, class T2>
struct has_operator_equal_impl {
template <class U, class V>
static auto check(U *) -> decltype(std::declval<U>() == std::declval<V>());
template <typename, typename>
static auto check(...) -> std::false_type;
using type = typename std::is_same<bool, decltype(check<T1, T2>(0))>::type;
};
} // namespace internal
template <class T1, class T2 = T1>
struct has_operator_equal : internal::has_operator_equal_impl<T1, T2>::type {};
} // namespace eigenpy
#include "eigenpy/alignment.hpp"
......
......@@ -319,24 +319,9 @@ struct StdContainerFromPythonList {
namespace internal {
template <typename T>
struct has_operator_equal
: boost::mpl::if_<typename boost::is_base_of<Eigen::EigenBase<T>, T>::type,
has_operator_equal<Eigen::EigenBase<T> >,
boost::true_type>::type {};
template <typename T, class A>
struct has_operator_equal<std::vector<T, A> > : has_operator_equal<T> {};
template <>
struct has_operator_equal<bool> : boost::true_type {};
template <typename EigenObject>
struct has_operator_equal<Eigen::EigenBase<EigenObject> >
: has_operator_equal<typename EigenObject::Scalar> {};
template <typename T, bool has_operator_equal_value = boost::is_base_of<
boost::true_type, has_operator_equal<T> >::value>
template <typename T,
bool has_operator_equal_value =
std::is_base_of<std::true_type, has_operator_equal<T> >::value>
struct contains_algo;
template <typename T>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment