add extLong constructor from std::size_t

try to workaround compilation issue on windows
This commit is contained in:
Sébastien Loriot 2024-03-21 11:01:34 +01:00
parent 92ef575127
commit 7d3bd7107a
1 changed files with 17 additions and 0 deletions

View File

@ -31,6 +31,9 @@
#include <CGAL/CORE/Impl.h>
#include <CGAL/CORE/CoreAux.h>
#include <limits>
#include <type_traits>
namespace CORE {
#ifndef LONG_MAX
@ -77,6 +80,9 @@ public:
extLong(long);
/// constructor for \c unsigned long
extLong(unsigned long);
/// constructor for \c std::size_t
template<typename = std::enable_if_t<!std::is_same_v<unsigned long, std::size_t>>>
extLong(std::size_t s);
//@}
/// \name Arithmetic and assignment operators
@ -188,6 +194,17 @@ inline extLong::extLong(unsigned long u) {
}
}
template <typename>
inline extLong::extLong(std::size_t u) {
if (u >= (std::numeric_limits<std::size_t>::max)()) {
val = EXTLONG_MAX;
flag = 1;
} else {
val = static_cast<long>(u);
flag = 0;
}
}
// isNaN defaults to false
inline extLong::extLong(bool isNaN) : val(0), flag(0) {
if (isNaN) {