diff --git a/include/decimal.h b/include/decimal.h index 3378d0a..7cb0e81 100644 --- a/include/decimal.h +++ b/include/decimal.h @@ -78,6 +78,19 @@ #define DEC_OVERRIDE override #endif +#ifdef DEC_NO_CPP11 +#define DEC_CONSTEXPR const +#else +#define DEC_CONSTEXPR constexpr +#endif + +#ifdef DEC_NO_CPP11 + #define DEC_MOVE(x) (x) +#else + #include + #define DEC_MOVE(x) std::move(x) +#endif + #if (DEC_ALLOW_SPACESHIP_OPER == 1) && (__cplusplus > 201703L) #define DEC_USE_SPACESHIP_OPER 1 #else @@ -188,27 +201,27 @@ enum { // Class definitions // ---------------------------------------------------------------------------- template struct DecimalFactor { - static const int64 value = 10 * DecimalFactor::value; + static DEC_CONSTEXPR int64 value = 10 * DecimalFactor::value; }; template<> struct DecimalFactor<0> { - static const int64 value = 1; + static DEC_CONSTEXPR int64 value = 1; }; template<> struct DecimalFactor<1> { - static const int64 value = 10; + static DEC_CONSTEXPR int64 value = 10; }; template struct DecimalFactorDiff_impl { - static const int64 value = DecimalFactor::value; + static DEC_CONSTEXPR int64 value = DecimalFactor::value; }; template struct DecimalFactorDiff_impl { - static const int64 value = INT64_MIN; + static DEC_CONSTEXPR int64 value = INT64_MIN; }; template struct DecimalFactorDiff { - static const int64 value = DecimalFactorDiff_impl= 0>::value; + static DEC_CONSTEXPR int64 value = DecimalFactorDiff_impl= 0>::value; }; #ifndef DEC_EXTERNAL_ROUND @@ -1935,7 +1948,7 @@ bool fromStream(StreamType &input, const basic_decimal_format &format, decimal_t ostringstream out; toStream(arg, format, out); - output = out.str(); + output = DEC_MOVE(out.str()); return output; } @@ -1946,7 +1959,7 @@ bool fromStream(StreamType &input, const basic_decimal_format &format, decimal_t ostringstream out; toStream(arg, out); - output = out.str(); + output = DEC_MOVE(out.str()); return output; }