Skip to content

Commit

Permalink
switch to fmt constexpr macros
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldreik committed Jun 9, 2019
1 parent c23fa59 commit 87d2c99
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions include/fmt/safe_duration_cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@

#include "format.h"

// see
// https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros#C.2B.2B17

#if __cpp_constexpr >= 201304
# define SDC_RELAXED_CONSTEXPR constexpr
#else
# define SDC_RELAXED_CONSTEXPR
#endif

FMT_BEGIN_NAMESPACE

namespace safe_duration_cast {
Expand All @@ -35,8 +26,7 @@ namespace safe_duration_cast {
*/
template <typename To, typename From,
FMT_ENABLE_IF(!std::is_same<From, To>::value)>
SDC_RELAXED_CONSTEXPR To lossless_integral_conversion(const From from,
int& ec) {
FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) {
ec = 0;
using F = std::numeric_limits<From>;
using T = std::numeric_limits<To>;
Expand Down Expand Up @@ -97,8 +87,7 @@ SDC_RELAXED_CONSTEXPR To lossless_integral_conversion(const From from,

template <typename To, typename From,
FMT_ENABLE_IF(std::is_same<From, To>::value)>
SDC_RELAXED_CONSTEXPR To lossless_integral_conversion(const From from,
int& ec) {
FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) {
ec = 0;
return from;
} // function
Expand All @@ -116,7 +105,7 @@ SDC_RELAXED_CONSTEXPR To lossless_integral_conversion(const From from,
*/
template <typename To, typename From,
FMT_ENABLE_IF(!std::is_same<From, To>::value)>
SDC_RELAXED_CONSTEXPR To safe_float_conversion(const From from, int& ec) {
FMT_CONSTEXPR To safe_float_conversion(const From from, int& ec) {
ec = 0;
using T = std::numeric_limits<To>;
static_assert(std::is_floating_point<From>::value, "From must be floating");
Expand All @@ -138,7 +127,7 @@ SDC_RELAXED_CONSTEXPR To safe_float_conversion(const From from, int& ec) {

template <typename To, typename From,
FMT_ENABLE_IF(std::is_same<From, To>::value)>
SDC_RELAXED_CONSTEXPR To safe_float_conversion(const From from, int& ec) {
FMT_CONSTEXPR To safe_float_conversion(const From from, int& ec) {
ec = 0;
static_assert(std::is_floating_point<From>::value, "From must be floating");
return from;
Expand Down

0 comments on commit 87d2c99

Please sign in to comment.