Skip to content

Commit 731ccef

Browse files
committed
Make fabs() private
Signed-off-by: Darby Johnston <[email protected]>
1 parent 5ed86fe commit 731ccef

File tree

2 files changed

+36
-19
lines changed

2 files changed

+36
-19
lines changed

src/opentime/rationalTime.h

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,6 @@ enum OPENTIME_EXPORT IsDropFrameRate : int
2020
ForceYes = 1,
2121
};
2222

23-
/// @brief Returns the absolute value.
24-
///
25-
/// \todo This function is used instead of "std::fabs()" so we can mark it as
26-
/// constexpr. We can remove this and replace it with the std version when we
27-
/// upgrade to C++ 23.
28-
///
29-
/// \todo Remove this function from the public API.
30-
constexpr double
31-
fabs(double val) noexcept
32-
{
33-
union
34-
{
35-
double f;
36-
uint64_t i;
37-
} bits = { val };
38-
bits.i &= std::numeric_limits<uint64_t>::max() / 2;
39-
return bits.f;
40-
}
41-
4223
/// @brief This class represents a measure of time defined by a value and rate.
4324
class OPENTIME_EXPORT RationalTime
4425
{
@@ -423,6 +404,24 @@ class OPENTIME_EXPORT RationalTime
423404
friend class TimeRange;
424405

425406
double _value, _rate;
407+
408+
/// @brief Returns the absolute value.
409+
///
410+
/// \todo This function is used instead of "std::fabs()" so we can mark it as
411+
/// constexpr. We can remove this and replace it with the std version when we
412+
/// upgrade to C++ 23. There are two copies of this function, in both
413+
/// RationalTime and TimeRange.
414+
static constexpr double
415+
fabs(double val) noexcept
416+
{
417+
union
418+
{
419+
double f;
420+
uint64_t i;
421+
} bits = { val };
422+
bits.i &= std::numeric_limits<uint64_t>::max() / 2;
423+
return bits.f;
424+
}
426425
};
427426

428427
}} // namespace opentime::OPENTIME_VERSION

src/opentime/timeRange.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,24 @@ class OPENTIME_EXPORT TimeRange
441441
{
442442
return rhs - lhs >= epsilon;
443443
}
444+
445+
/// @brief Returns the absolute value.
446+
///
447+
/// \todo This function is used instead of "std::fabs()" so we can mark it as
448+
/// constexpr. We can remove this and replace it with the std version when we
449+
/// upgrade to C++ 23. There are two copies of this function, in both
450+
/// RationalTime and TimeRange.
451+
static constexpr double
452+
fabs(double val) noexcept
453+
{
454+
union
455+
{
456+
double f;
457+
uint64_t i;
458+
} bits = { val };
459+
bits.i &= std::numeric_limits<uint64_t>::max() / 2;
460+
return bits.f;
461+
}
444462
};
445463

446464
}} // namespace opentime::OPENTIME_VERSION

0 commit comments

Comments
 (0)