Converters now simply forward fundamental types, forbid others

This commit is contained in:
Mael Rouxel-Labbé 2021-12-03 16:48:51 +01:00
parent 5aa34c9106
commit 71cbd212dc
3 changed files with 37 additions and 24 deletions

View File

@ -127,14 +127,20 @@ public:
} }
template <typename T> template <typename T>
typename K2::FT T
operator()(const T&, operator()(const T t,
typename std::enable_if<std::is_fundamental<T>::value>::type* = nullptr) const typename std::enable_if<std::is_fundamental<T>::value>::type* = nullptr) const
{ {
// Disable fundamental types (other than K1::FT) to avoid unexpected results return t;
// More details: https://github.com/CGAL/cgal/issues/4982 }
CGAL_static_assertion(!(std::is_fundamental<T>::value));
return typename K2::FT(); template <typename T>
T
operator()(const T t,
typename std::enable_if<!std::is_fundamental<T>::value>::type* = nullptr) const
{
CGAL_static_assertion(!(std::is_same<T, T>::value));
return t;
} }
// drop the boost::detail::variant::void_ generated by the macros // drop the boost::detail::variant::void_ generated by the macros

View File

@ -87,14 +87,20 @@ public:
} }
template <typename T> template <typename T>
typename K2::FT T
operator()(const T&, operator()(const T t,
typename std::enable_if<std::is_fundamental<T>::value>::type* = nullptr) typename std::enable_if<std::is_fundamental<T>::value>::type* = nullptr) const
{ {
// Disable fundamental types (other than K1::FT) to avoid unexpected results return t;
// More details: https://github.com/CGAL/cgal/issues/4982 }
CGAL_static_assertion(!(std::is_fundamental<T>::value));
return typename K2::FT(); template <typename T>
T
operator()(const T t,
typename std::enable_if<!std::is_fundamental<T>::value>::type* = nullptr) const
{
CGAL_static_assertion(!(std::is_same<T, T>::value));
return t;
} }
typename K2::Point_2 typename K2::Point_2

View File

@ -100,14 +100,20 @@ public:
} }
template <typename T> template <typename T>
typename K2::FT T
operator()(const T&, operator()(const T t,
typename std::enable_if<std::is_fundamental<T>::value>::type* = nullptr) const typename std::enable_if<std::is_fundamental<T>::value>::type* = nullptr) const
{ {
// Disable fundamental types (other than K1::FT) to avoid unexpected results return t;
// More details: https://github.com/CGAL/cgal/issues/4982 }
CGAL_static_assertion(!(std::is_fundamental<T>::value));
return typename K2::FT(); template <typename T>
T
operator()(const T t,
typename std::enable_if<!std::is_fundamental<T>::value>::type* = nullptr) const
{
CGAL_static_assertion(!(std::is_same<T, T>::value));
return t;
} }
std::vector<Object> std::vector<Object>
@ -121,11 +127,6 @@ public:
return res; return res;
} }
int operator()(const int &a)
{
return a;
}
typename K2::Point_d typename K2::Point_d
operator()(const typename K1::Point_d &a) const operator()(const typename K1::Point_d &a) const
{ {