示例#1
0
namespace fmt {

#ifndef _MSC_VER
# define FMT_SNPRINTF snprintf
#else  // _MSC_VER
inline int fmt_snprintf(char *buffer, size_t size, const char *format, ...) {
    va_list args;
    va_start(args, format);
    int result = vsnprintf_s(buffer, size, _TRUNCATE, format, args);
    va_end(args);
    return result;
}
# define FMT_SNPRINTF fmt_snprintf
#endif  // _MSC_VER

const char fmt::internal::BasicData::DIGITS[] =
        "0001020304050607080910111213141516171819"
        "2021222324252627282930313233343536373839"
        "4041424344454647484950515253545556575859"
        "6061626364656667686970717273747576777879"
        "8081828384858687888990919293949596979899";

#define FMT_POWERS_OF_10(factor) \
    factor * 10, \
    factor * 100, \
    factor * 1000, \
    factor * 10000, \
    factor * 100000, \
    factor * 1000000, \
    factor * 10000000, \
    factor * 100000000, \
    factor * 1000000000

const uint32_t internal::BasicData::POWERS_OF_10_32[] = {
    0, FMT_POWERS_OF_10(1)
};

const uint64_t internal::BasicData::POWERS_OF_10_64[] = {
    0,
    FMT_POWERS_OF_10(1),
    FMT_POWERS_OF_10(fmt::ULongLong(1000000000)),
    // Multiply several constants instead of using a single long long constant
    // to avoid warnings about C++98 not supporting long long.
    fmt::ULongLong(1000000000) * fmt::ULongLong(1000000000) * 10
};
}
    "8081828384858687888990919293949596979899";

#define FMT_POWERS_OF_10(factor) \
  factor * 10, \
  factor * 100, \
  factor * 1000, \
  factor * 10000, \
  factor * 100000, \
  factor * 1000000, \
  factor * 10000000, \
  factor * 100000000, \
  factor * 1000000000

template <typename T>
const uint32_t basic_data<T>::POWERS_OF_10_32[] = {
  1, FMT_POWERS_OF_10(1)
};

template <typename T>
const uint32_t basic_data<T>::ZERO_OR_POWERS_OF_10_32[] = {
  0, FMT_POWERS_OF_10(1)
};

template <typename T>
const uint64_t basic_data<T>::ZERO_OR_POWERS_OF_10_64[] = {
  0,
  FMT_POWERS_OF_10(1),
  FMT_POWERS_OF_10(1000000000ull),
  10000000000000000000ull
};