mirror of
https://github.com/fmtlib/fmt.git
synced 2025-12-24 15:58:16 +01:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
135ab5cf71 | ||
|
|
93d95f17c6 | ||
|
|
4f15c72f69 | ||
|
|
e9b194141e | ||
|
|
c3d1f6040b | ||
|
|
c96062bff5 |
@@ -3,11 +3,11 @@ message(STATUS "CMake version: ${CMAKE_VERSION}")
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
|
||||
if (POLICY CMP0048) # Version variables
|
||||
cmake_policy(SET CMP0048 NEW)
|
||||
cmake_policy(SET CMP0048 OLD)
|
||||
endif ()
|
||||
|
||||
if (POLICY CMP0063) # Visibility
|
||||
cmake_policy(SET CMP0063 NEW)
|
||||
cmake_policy(SET CMP0063 OLD)
|
||||
endif (POLICY CMP0063)
|
||||
|
||||
# Determine if fmt is built as a subproject (using add_subdirectory)
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
4.1.1 - TBD
|
||||
------------
|
||||
|
||||
4.1.0 - 2017-12-20
|
||||
------------------
|
||||
|
||||
|
||||
@@ -35,8 +35,6 @@ If the numerical arg_ids in a format string are 0, 1, 2, ... in sequence,
|
||||
they can all be omitted (not just some) and the numbers 0, 1, 2, ... will be
|
||||
automatically inserted in that order.
|
||||
|
||||
Named arguments can be referred to by their names or indices.
|
||||
|
||||
Some simple format string examples::
|
||||
|
||||
"First, thou shalt count to {0}" // References the first argument
|
||||
|
||||
@@ -24,7 +24,6 @@ target_include_directories(fmt PUBLIC
|
||||
|
||||
set_target_properties(fmt PROPERTIES
|
||||
VERSION ${FMT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR})
|
||||
set_target_properties(fmt PROPERTIES DEBUG_POSTFIX d)
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
if (UNIX AND NOT APPLE)
|
||||
|
||||
@@ -30,9 +30,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <cctype>
|
||||
#if !defined(UNDER_CE)
|
||||
# include <cerrno>
|
||||
#endif
|
||||
#include <cerrno>
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
#include <cstdarg>
|
||||
@@ -85,10 +83,7 @@ static inline fmt::internal::Null<> strerror_s(char *, std::size_t, ...) {
|
||||
|
||||
namespace fmt {
|
||||
|
||||
namespace internal {
|
||||
FMT_FUNC RuntimeError::~RuntimeError() FMT_DTOR_NOEXCEPT {}
|
||||
} // namespace internal
|
||||
|
||||
FMT_FUNC internal::RuntimeError::~RuntimeError() FMT_DTOR_NOEXCEPT {}
|
||||
FMT_FUNC FormatError::~FormatError() FMT_DTOR_NOEXCEPT {}
|
||||
FMT_FUNC SystemError::~SystemError() FMT_DTOR_NOEXCEPT {}
|
||||
|
||||
@@ -100,11 +95,7 @@ namespace {
|
||||
inline int fmt_snprintf(char *buffer, size_t size, const char *format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
# if !defined(UNDER_CE)
|
||||
int result = vsnprintf_s(buffer, size, _TRUNCATE, format, args);
|
||||
# else
|
||||
int result = _vsnprintf_s(buffer, size, _TRUNCATE, format, args);
|
||||
# endif
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
@@ -114,11 +105,7 @@ inline int fmt_snprintf(char *buffer, size_t size, const char *format, ...) {
|
||||
#if defined(_WIN32) && defined(__MINGW32__) && !defined(__NO_ISOCEXT)
|
||||
# define FMT_SWPRINTF snwprintf
|
||||
#else
|
||||
# if defined(UNDER_CE)
|
||||
# define FMT_SWPRINTF swprintf_s
|
||||
# else
|
||||
# define FMT_SWPRINTF swprintf
|
||||
#endif
|
||||
# define FMT_SWPRINTF swprintf
|
||||
#endif // defined(_WIN32) && defined(__MINGW32__) && !defined(__NO_ISOCEXT)
|
||||
|
||||
const char RESET_COLOR[] = "\x1b[0m";
|
||||
@@ -147,13 +134,11 @@ int safe_strerror(
|
||||
// A noop assignment operator to avoid bogus warnings.
|
||||
void operator=(const StrError &) {}
|
||||
|
||||
#if !defined(UNDER_CE)
|
||||
// Handle the result of XSI-compliant version of strerror_r.
|
||||
int handle(int result) {
|
||||
// glibc versions before 2.13 return result in errno.
|
||||
return result == -1 ? errno : result;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Handle the result of GNU-specific version of strerror_r.
|
||||
int handle(char *message) {
|
||||
@@ -176,23 +161,19 @@ int safe_strerror(
|
||||
ERANGE : result;
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
#ifdef __c2__
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
// Fallback to strerror if strerror_r and strerror_s are not available.
|
||||
int fallback(internal::Null<>) {
|
||||
#if !defined(UNDER_CE)
|
||||
errno = 0;
|
||||
buffer_ = strerror(error_code_);
|
||||
return errno;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
#ifdef __c2__
|
||||
# pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
@@ -250,9 +231,8 @@ FMT_FUNC void SystemError::init(
|
||||
base = std::runtime_error(w.str());
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
template <typename T>
|
||||
int CharTraits<char>::format_float(
|
||||
int internal::CharTraits<char>::format_float(
|
||||
char *buffer, std::size_t size, const char *format,
|
||||
unsigned width, int precision, T value) {
|
||||
if (width == 0) {
|
||||
@@ -266,7 +246,7 @@ int CharTraits<char>::format_float(
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int CharTraits<wchar_t>::format_float(
|
||||
int internal::CharTraits<wchar_t>::format_float(
|
||||
wchar_t *buffer, std::size_t size, const wchar_t *format,
|
||||
unsigned width, int precision, T value) {
|
||||
if (width == 0) {
|
||||
@@ -280,7 +260,7 @@ int CharTraits<wchar_t>::format_float(
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const char BasicData<T>::DIGITS[] =
|
||||
const char internal::BasicData<T>::DIGITS[] =
|
||||
"0001020304050607080910111213141516171819"
|
||||
"2021222324252627282930313233343536373839"
|
||||
"4041424344454647484950515253545556575859"
|
||||
@@ -299,12 +279,12 @@ const char BasicData<T>::DIGITS[] =
|
||||
factor * 1000000000
|
||||
|
||||
template <typename T>
|
||||
const uint32_t BasicData<T>::POWERS_OF_10_32[] = {
|
||||
const uint32_t internal::BasicData<T>::POWERS_OF_10_32[] = {
|
||||
0, FMT_POWERS_OF_10(1)
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
const uint64_t BasicData<T>::POWERS_OF_10_64[] = {
|
||||
const uint64_t internal::BasicData<T>::POWERS_OF_10_64[] = {
|
||||
0,
|
||||
FMT_POWERS_OF_10(1),
|
||||
FMT_POWERS_OF_10(ULongLong(1000000000)),
|
||||
@@ -313,7 +293,7 @@ const uint64_t BasicData<T>::POWERS_OF_10_64[] = {
|
||||
ULongLong(1000000000) * ULongLong(1000000000) * 10
|
||||
};
|
||||
|
||||
FMT_FUNC void report_unknown_type(char code, const char *type) {
|
||||
FMT_FUNC void internal::report_unknown_type(char code, const char *type) {
|
||||
(void)type;
|
||||
if (std::isprint(static_cast<unsigned char>(code))) {
|
||||
FMT_THROW(FormatError(
|
||||
@@ -326,7 +306,7 @@ FMT_FUNC void report_unknown_type(char code, const char *type) {
|
||||
|
||||
#if FMT_USE_WINDOWS_H
|
||||
|
||||
FMT_FUNC UTF8ToUTF16::UTF8ToUTF16(StringRef s) {
|
||||
FMT_FUNC internal::UTF8ToUTF16::UTF8ToUTF16(StringRef s) {
|
||||
static const char ERROR_MSG[] = "cannot convert string from UTF-8 to UTF-16";
|
||||
if (s.size() > INT_MAX)
|
||||
FMT_THROW(WindowsError(ERROR_INVALID_PARAMETER, ERROR_MSG));
|
||||
@@ -343,14 +323,14 @@ FMT_FUNC UTF8ToUTF16::UTF8ToUTF16(StringRef s) {
|
||||
buffer_[length] = 0;
|
||||
}
|
||||
|
||||
FMT_FUNC UTF16ToUTF8::UTF16ToUTF8(WStringRef s) {
|
||||
FMT_FUNC internal::UTF16ToUTF8::UTF16ToUTF8(WStringRef s) {
|
||||
if (int error_code = convert(s)) {
|
||||
FMT_THROW(WindowsError(error_code,
|
||||
"cannot convert string from UTF-16 to UTF-8"));
|
||||
}
|
||||
}
|
||||
|
||||
FMT_FUNC int UTF16ToUTF8::convert(WStringRef s) {
|
||||
FMT_FUNC int internal::UTF16ToUTF8::convert(WStringRef s) {
|
||||
if (s.size() > INT_MAX)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
int s_size = static_cast<int>(s.size());
|
||||
@@ -366,7 +346,6 @@ FMT_FUNC int UTF16ToUTF8::convert(WStringRef s) {
|
||||
buffer_[length] = 0;
|
||||
return 0;
|
||||
}
|
||||
} // namespace internal
|
||||
|
||||
FMT_FUNC void WindowsError::init(
|
||||
int err_code, CStringRef format_str, ArgList args) {
|
||||
@@ -377,8 +356,7 @@ FMT_FUNC void WindowsError::init(
|
||||
base = std::runtime_error(w.str());
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
FMT_FUNC void format_windows_error(
|
||||
FMT_FUNC void internal::format_windows_error(
|
||||
Writer &out, int error_code, StringRef message) FMT_NOEXCEPT {
|
||||
FMT_TRY {
|
||||
MemoryBuffer<wchar_t, INLINE_BUFFER_SIZE> buffer;
|
||||
@@ -406,7 +384,7 @@ FMT_FUNC void format_windows_error(
|
||||
}
|
||||
|
||||
#endif // FMT_USE_WINDOWS_H
|
||||
} // namespace internal
|
||||
|
||||
FMT_FUNC void format_system_error(
|
||||
Writer &out, int error_code, StringRef message) FMT_NOEXCEPT {
|
||||
FMT_TRY {
|
||||
@@ -426,37 +404,38 @@ FMT_FUNC void format_system_error(
|
||||
} FMT_CATCH(...) {}
|
||||
fmt::format_error_code(out, error_code, message); // 'fmt::' is for bcc32.
|
||||
}
|
||||
} // namespace fmt
|
||||
|
||||
template <typename Char>
|
||||
void fmt::internal::FixedBuffer<Char>::grow(std::size_t) {
|
||||
void internal::FixedBuffer<Char>::grow(std::size_t) {
|
||||
FMT_THROW(std::runtime_error("buffer overflow"));
|
||||
}
|
||||
|
||||
FMT_FUNC fmt::internal::Arg fmt::internal::FormatterBase::do_get_arg(
|
||||
FMT_FUNC internal::Arg internal::FormatterBase::do_get_arg(
|
||||
unsigned arg_index, const char *&error) {
|
||||
fmt::internal::Arg arg = args_[arg_index];
|
||||
internal::Arg arg = args_[arg_index];
|
||||
switch (arg.type) {
|
||||
case fmt::internal::Arg::NONE:
|
||||
case internal::Arg::NONE:
|
||||
error = "argument index out of range";
|
||||
break;
|
||||
case fmt::internal::Arg::NAMED_ARG:
|
||||
arg = *static_cast<const fmt::internal::Arg*>(arg.pointer);
|
||||
case internal::Arg::NAMED_ARG:
|
||||
arg = *static_cast<const internal::Arg*>(arg.pointer);
|
||||
break;
|
||||
default:
|
||||
/*nothing*/;
|
||||
}
|
||||
return arg;
|
||||
}
|
||||
namespace fmt {
|
||||
|
||||
FMT_FUNC void report_system_error(
|
||||
int error_code, StringRef message) FMT_NOEXCEPT {
|
||||
int error_code, fmt::StringRef message) FMT_NOEXCEPT {
|
||||
// 'fmt::' is for bcc32.
|
||||
report_error(format_system_error, error_code, message);
|
||||
}
|
||||
|
||||
#if FMT_USE_WINDOWS_H
|
||||
FMT_FUNC void report_windows_error(
|
||||
int error_code, StringRef message) FMT_NOEXCEPT {
|
||||
int error_code, fmt::StringRef message) FMT_NOEXCEPT {
|
||||
// 'fmt::' is for bcc32.
|
||||
report_error(internal::format_windows_error, error_code, message);
|
||||
}
|
||||
#endif
|
||||
@@ -484,29 +463,28 @@ FMT_FUNC void print_colored(Color c, CStringRef format, ArgList args) {
|
||||
template struct internal::BasicData<void>;
|
||||
|
||||
// Explicit instantiations for char.
|
||||
namespace internal {
|
||||
template void FixedBuffer<char>::grow(std::size_t);
|
||||
|
||||
template FMT_API int CharTraits<char>::format_float(
|
||||
template void internal::FixedBuffer<char>::grow(std::size_t);
|
||||
|
||||
template FMT_API int internal::CharTraits<char>::format_float(
|
||||
char *buffer, std::size_t size, const char *format,
|
||||
unsigned width, int precision, double value);
|
||||
|
||||
template FMT_API int CharTraits<char>::format_float(
|
||||
template FMT_API int internal::CharTraits<char>::format_float(
|
||||
char *buffer, std::size_t size, const char *format,
|
||||
unsigned width, int precision, long double value);
|
||||
|
||||
// Explicit instantiations for wchar_t.
|
||||
|
||||
template void FixedBuffer<wchar_t>::grow(std::size_t);
|
||||
template void internal::FixedBuffer<wchar_t>::grow(std::size_t);
|
||||
|
||||
template FMT_API int CharTraits<wchar_t>::format_float(
|
||||
template FMT_API int internal::CharTraits<wchar_t>::format_float(
|
||||
wchar_t *buffer, std::size_t size, const wchar_t *format,
|
||||
unsigned width, int precision, double value);
|
||||
|
||||
template FMT_API int CharTraits<wchar_t>::format_float(
|
||||
template FMT_API int internal::CharTraits<wchar_t>::format_float(
|
||||
wchar_t *buffer, std::size_t size, const wchar_t *format,
|
||||
unsigned width, int precision, long double value);
|
||||
} //namespace internal
|
||||
|
||||
#endif // FMT_HEADER_ONLY
|
||||
|
||||
|
||||
139
fmt/format.h
139
fmt/format.h
@@ -25,11 +25,6 @@
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// transition helper
|
||||
#ifdef FMT_FORMAT_PROVIDE_PRINTF
|
||||
#include "printf.h"
|
||||
#endif
|
||||
|
||||
#ifndef FMT_FORMAT_H_
|
||||
#define FMT_FORMAT_H_
|
||||
|
||||
@@ -48,7 +43,7 @@
|
||||
#undef FMT_INCLUDE
|
||||
|
||||
// The fmt library version in the form major * 10000 + minor * 100 + patch.
|
||||
#define FMT_VERSION 40101
|
||||
#define FMT_VERSION 40100
|
||||
|
||||
#if defined(__has_include)
|
||||
# define FMT_HAS_INCLUDE(x) __has_include(x)
|
||||
@@ -60,15 +55,8 @@
|
||||
(defined(_MSVC_LANG) && _MSVC_LANG > 201402L && _MSC_VER >= 1910)
|
||||
# include <string_view>
|
||||
# define FMT_HAS_STRING_VIEW 1
|
||||
# define FMT_HAS_EXPERIMENTAL_STRING_VIEW 0
|
||||
#else
|
||||
# define FMT_HAS_STRING_VIEW 0
|
||||
# if (FMT_HAS_INCLUDE(<experimental/string_view>) && __cplusplus >= 201402L)
|
||||
# include <experimental/string_view>
|
||||
# define FMT_HAS_EXPERIMENTAL_STRING_VIEW 1
|
||||
# else
|
||||
# define FMT_HAS_EXPERIMENTAL_STRING_VIEW 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined _SECURE_SCL && _SECURE_SCL
|
||||
@@ -130,11 +118,6 @@ typedef __int64 intmax_t;
|
||||
# define FMT_HAS_GXX_CXX11 0
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma warn -8072 // disable "suspicious pointer arithmetic" warning on access of the digits array
|
||||
#pragma warn -8004 // disable "assigned value that is never used" warning
|
||||
#endif
|
||||
|
||||
#if defined(__INTEL_COMPILER)
|
||||
# define FMT_ICC_VERSION __INTEL_COMPILER
|
||||
#elif defined(__ICL)
|
||||
@@ -370,7 +353,7 @@ typedef __int64 intmax_t;
|
||||
// otherwise support __builtin_clz and __builtin_clzll, so
|
||||
// only define FMT_BUILTIN_CLZ using the MSVC intrinsics
|
||||
// if the clz and clzll builtins are not available.
|
||||
#if FMT_MSC_VER && !defined(FMT_BUILTIN_CLZLL) && !defined(_MANAGED) && !defined(UNDER_CE)
|
||||
#if FMT_MSC_VER && !defined(FMT_BUILTIN_CLZLL) && !defined(_MANAGED)
|
||||
# include <intrin.h> // _BitScanReverse, _BitScanReverse64
|
||||
|
||||
namespace fmt {
|
||||
@@ -461,7 +444,8 @@ class numeric_limits<fmt::internal::DummyInt> :
|
||||
using namespace fmt::internal;
|
||||
// The resolution "priority" is:
|
||||
// isinf macro > std::isinf > ::isinf > fmt::internal::isinf
|
||||
if (const_check(sizeof(isinf(x)) != sizeof(fmt::internal::DummyInt))) {
|
||||
if (const_check(sizeof(isinf(x)) == sizeof(bool) ||
|
||||
sizeof(isinf(x)) == sizeof(int))) {
|
||||
return isinf(x) != 0;
|
||||
}
|
||||
return !_finite(static_cast<double>(x));
|
||||
@@ -471,7 +455,8 @@ class numeric_limits<fmt::internal::DummyInt> :
|
||||
template <typename T>
|
||||
static bool isnotanumber(T x) {
|
||||
using namespace fmt::internal;
|
||||
if (const_check(sizeof(isnan(x)) != sizeof(fmt::internal::DummyInt))) {
|
||||
if (const_check(sizeof(isnan(x)) == sizeof(bool) ||
|
||||
sizeof(isnan(x)) == sizeof(int))) {
|
||||
return isnan(x) != 0;
|
||||
}
|
||||
return _isnan(static_cast<double>(x)) != 0;
|
||||
@@ -480,7 +465,8 @@ class numeric_limits<fmt::internal::DummyInt> :
|
||||
// Portable version of signbit.
|
||||
static bool isnegative(double x) {
|
||||
using namespace fmt::internal;
|
||||
if (const_check(sizeof(signbit(x)) != sizeof(fmt::internal::DummyInt))) {
|
||||
if (const_check(sizeof(signbit(x)) == sizeof(bool) ||
|
||||
sizeof(signbit(x)) == sizeof(int))) {
|
||||
return signbit(x) != 0;
|
||||
}
|
||||
if (x < 0) return true;
|
||||
@@ -596,26 +582,6 @@ class BasicStringRef {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if FMT_HAS_EXPERIMENTAL_STRING_VIEW
|
||||
/**
|
||||
\rst
|
||||
Constructs a string reference from a ``std::experimental::basic_string_view`` object.
|
||||
\endrst
|
||||
*/
|
||||
BasicStringRef(
|
||||
const std::experimental::basic_string_view<Char, std::char_traits<Char>> &s)
|
||||
: data_(s.data()), size_(s.size()) {}
|
||||
|
||||
/**
|
||||
\rst
|
||||
Converts a string reference to an ``std::string_view`` object.
|
||||
\endrst
|
||||
*/
|
||||
explicit operator std::experimental::basic_string_view<Char>() const FMT_NOEXCEPT {
|
||||
return std::experimental::basic_string_view<Char>(data_, size_);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
\rst
|
||||
Converts a string reference to an ``std::string`` object.
|
||||
@@ -715,12 +681,12 @@ typedef BasicCStringRef<char> CStringRef;
|
||||
typedef BasicCStringRef<wchar_t> WCStringRef;
|
||||
|
||||
/** A formatting error such as invalid format string. */
|
||||
class FMT_API FormatError : public std::runtime_error {
|
||||
class FormatError : public std::runtime_error {
|
||||
public:
|
||||
explicit FormatError(CStringRef message)
|
||||
: std::runtime_error(message.c_str()) {}
|
||||
FormatError(const FormatError &ferr) : std::runtime_error(ferr) {}
|
||||
~FormatError() FMT_DTOR_NOEXCEPT FMT_OVERRIDE;
|
||||
FMT_API ~FormatError() FMT_DTOR_NOEXCEPT FMT_OVERRIDE;
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
@@ -1032,7 +998,7 @@ struct IntTraits {
|
||||
TypeSelector<std::numeric_limits<T>::digits <= 32>::Type MainType;
|
||||
};
|
||||
|
||||
FMT_NORETURN FMT_API void report_unknown_type(char code, const char *type);
|
||||
FMT_API FMT_NORETURN void report_unknown_type(char code, const char *type);
|
||||
|
||||
// Static data is placed in this class template to allow header-only
|
||||
// configuration.
|
||||
@@ -1292,7 +1258,6 @@ struct ConvertToIntImpl2<T, true> {
|
||||
template <typename T>
|
||||
struct ConvertToInt {
|
||||
enum {
|
||||
#pragma warning(suppress: 4244)
|
||||
enable_conversion = sizeof(fmt::internal::convert(get<T>())) == sizeof(Yes)
|
||||
};
|
||||
enum { value = ConvertToIntImpl2<T, enable_conversion>::value };
|
||||
@@ -1333,7 +1298,6 @@ template <typename T, T> struct LConvCheck {
|
||||
LConvCheck(int) {}
|
||||
};
|
||||
|
||||
#ifndef __BORLANDC__
|
||||
// Returns the thousands separator for the current locale.
|
||||
// We check if ``lconv`` contains ``thousands_sep`` because on Android
|
||||
// ``lconv`` is stubbed as an empty struct.
|
||||
@@ -1342,7 +1306,6 @@ inline StringRef thousands_sep(
|
||||
LConv *lc, LConvCheck<char *LConv::*, &LConv::thousands_sep> = 0) {
|
||||
return lc->thousands_sep;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline fmt::StringRef thousands_sep(...) { return ""; }
|
||||
|
||||
@@ -1404,9 +1367,6 @@ class MakeValue : public Arg {
|
||||
MakeValue(typename WCharHelper<const std::wstring &, Char>::Unsupported);
|
||||
#if FMT_HAS_STRING_VIEW
|
||||
MakeValue(typename WCharHelper<const std::wstring_view &, Char>::Unsupported);
|
||||
#endif
|
||||
#if FMT_HAS_EXPERIMENTAL_STRING_VIEW
|
||||
MakeValue(typename WCharHelper<const std::experimental::wstring_view &, Char>::Unsupported);
|
||||
#endif
|
||||
MakeValue(typename WCharHelper<WStringRef, Char>::Unsupported);
|
||||
|
||||
@@ -1511,9 +1471,6 @@ class MakeValue : public Arg {
|
||||
FMT_MAKE_STR_VALUE(const std::string &, STRING)
|
||||
#if FMT_HAS_STRING_VIEW
|
||||
FMT_MAKE_STR_VALUE(const std::string_view &, STRING)
|
||||
#endif
|
||||
#if FMT_HAS_EXPERIMENTAL_STRING_VIEW
|
||||
FMT_MAKE_STR_VALUE(const std::experimental::string_view &, STRING)
|
||||
#endif
|
||||
FMT_MAKE_STR_VALUE(StringRef, STRING)
|
||||
FMT_MAKE_VALUE_(CStringRef, string.value, CSTRING, value.c_str())
|
||||
@@ -1529,9 +1486,6 @@ class MakeValue : public Arg {
|
||||
FMT_MAKE_WSTR_VALUE(const std::wstring &, WSTRING)
|
||||
#if FMT_HAS_STRING_VIEW
|
||||
FMT_MAKE_WSTR_VALUE(const std::wstring_view &, WSTRING)
|
||||
#endif
|
||||
#if FMT_HAS_EXPERIMENTAL_STRING_VIEW
|
||||
FMT_MAKE_WSTR_VALUE(const std::experimental::wstring_view &, WSTRING)
|
||||
#endif
|
||||
FMT_MAKE_WSTR_VALUE(WStringRef, WSTRING)
|
||||
|
||||
@@ -2107,6 +2061,7 @@ void ArgMap<Char>::init(const ArgList &args) {
|
||||
/*nothing*/;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (unsigned i = 0; i != ArgList::MAX_PACKED_ARGS; ++i) {
|
||||
internal::Arg::Type arg_type = args.type(i);
|
||||
@@ -2145,8 +2100,6 @@ class ArgFormatterBase : public ArgVisitor<Impl, void> {
|
||||
|
||||
// workaround MSVC two-phase lookup issue
|
||||
typedef internal::Arg Arg;
|
||||
typedef Char CharType;
|
||||
typedef BasicWriter<Char> WriterType;
|
||||
|
||||
protected:
|
||||
BasicWriter<Char> &writer() { return writer_; }
|
||||
@@ -2191,8 +2144,8 @@ class ArgFormatterBase : public ArgVisitor<Impl, void> {
|
||||
}
|
||||
if (spec_.align_ == ALIGN_NUMERIC || spec_.flags_ != 0)
|
||||
FMT_THROW(FormatError("invalid format specifier for char"));
|
||||
typedef typename WriterType::CharPtr CharPtr;
|
||||
CharType fill = internal::CharTraits<CharType>::cast(spec_.fill());
|
||||
typedef typename BasicWriter<Char>::CharPtr CharPtr;
|
||||
Char fill = internal::CharTraits<Char>::cast(spec_.fill());
|
||||
CharPtr out = CharPtr();
|
||||
const unsigned CHAR_SIZE = 1;
|
||||
if (spec_.width_ > CHAR_SIZE) {
|
||||
@@ -2210,7 +2163,7 @@ class ArgFormatterBase : public ArgVisitor<Impl, void> {
|
||||
} else {
|
||||
out = writer_.grow_buffer(CHAR_SIZE);
|
||||
}
|
||||
*out = internal::CharTraits<CharType>::cast(value);
|
||||
*out = internal::CharTraits<Char>::cast(value);
|
||||
}
|
||||
|
||||
void visit_cstring(const char *value) {
|
||||
@@ -2412,7 +2365,6 @@ inline uint64_t make_type(const T &arg) {
|
||||
return MakeValue< BasicFormatter<char> >::type(arg);
|
||||
}
|
||||
|
||||
#ifndef __BORLANDC__
|
||||
template <std::size_t N, bool/*IsPacked*/= (N < ArgList::MAX_PACKED_ARGS)>
|
||||
struct ArgArray;
|
||||
|
||||
@@ -2442,25 +2394,6 @@ struct ArgArray<N, false/*IsPacked*/> {
|
||||
template <typename Formatter, typename T>
|
||||
static Arg make(const T &value) { return MakeArg<Formatter>(value); }
|
||||
};
|
||||
#else
|
||||
template <std::size_t N>
|
||||
struct ArgArray {
|
||||
typedef Value Type[N > 0 ? N : 1];
|
||||
|
||||
template <typename Formatter, typename T>
|
||||
static Value make(const T & value) {
|
||||
#ifdef __clang__
|
||||
Value result = MakeValue<Formatter>(value);
|
||||
// Workaround a bug in Apple LLVM version 4.2 (clang-425.0.28) of clang:
|
||||
// https://github.com/fmtlib/fmt/issues/276
|
||||
(void)result.custom.format;
|
||||
return result;
|
||||
#else
|
||||
return MakeValue<Formatter>(value);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#if FMT_USE_VARIADIC_TEMPLATES
|
||||
template <typename Arg, typename... Args>
|
||||
@@ -2497,8 +2430,6 @@ inline uint64_t make_type(FMT_GEN15(FMT_ARG_TYPE_DEFAULT)) {
|
||||
arr[n] = fmt::internal::MakeValue< fmt::BasicFormatter<char> >(v##n)
|
||||
# define FMT_ASSIGN_wchar_t(n) \
|
||||
arr[n] = fmt::internal::MakeValue< fmt::BasicFormatter<wchar_t> >(v##n)
|
||||
# define FMT_ASSIGN_Char(n) \
|
||||
arr[n] = fmt::internal::MakeValue< fmt::BasicFormatter<Char> >(v##n)
|
||||
|
||||
#if FMT_USE_VARIADIC_TEMPLATES
|
||||
// Defines a variadic function returning void.
|
||||
@@ -2532,10 +2463,9 @@ inline uint64_t make_type(FMT_GEN15(FMT_ARG_TYPE_DEFAULT)) {
|
||||
# define FMT_WRAP1(func, arg_type, n) \
|
||||
template <FMT_GEN(n, FMT_MAKE_TEMPLATE_ARG)> \
|
||||
inline void func(arg_type arg1, FMT_GEN(n, FMT_MAKE_ARG)) { \
|
||||
fmt::internal::ArgArray<n>::Type arr; \
|
||||
FMT_GEN(n, FMT_ASSIGN_Char) ; \
|
||||
const fmt::internal::ArgArray<n>::Type array = {FMT_GEN(n, FMT_MAKE_REF)}; \
|
||||
func(arg1, fmt::ArgList( \
|
||||
fmt::internal::make_type(FMT_GEN(n, FMT_MAKE_REF2)), arr)); \
|
||||
fmt::internal::make_type(FMT_GEN(n, FMT_MAKE_REF2)), array)); \
|
||||
}
|
||||
|
||||
// Emulates a variadic function returning void on a pre-C++11 compiler.
|
||||
@@ -2550,10 +2480,9 @@ inline uint64_t make_type(FMT_GEN15(FMT_ARG_TYPE_DEFAULT)) {
|
||||
# define FMT_CTOR(ctor, func, arg0_type, arg1_type, n) \
|
||||
template <FMT_GEN(n, FMT_MAKE_TEMPLATE_ARG)> \
|
||||
ctor(arg0_type arg0, arg1_type arg1, FMT_GEN(n, FMT_MAKE_ARG)) { \
|
||||
fmt::internal::ArgArray<n>::Type arr; \
|
||||
FMT_GEN(n, FMT_ASSIGN_Char) ; \
|
||||
const fmt::internal::ArgArray<n>::Type array = {FMT_GEN(n, FMT_MAKE_REF)}; \
|
||||
func(arg0, arg1, fmt::ArgList( \
|
||||
fmt::internal::make_type(FMT_GEN(n, FMT_MAKE_REF2)), arr)); \
|
||||
fmt::internal::make_type(FMT_GEN(n, FMT_MAKE_REF2)), array)); \
|
||||
}
|
||||
|
||||
// Emulates a variadic constructor on a pre-C++11 compiler.
|
||||
@@ -3033,13 +2962,13 @@ typename BasicWriter<Char>::CharPtr
|
||||
CharPtr p = grow_buffer(fill_size);
|
||||
std::uninitialized_fill(p, p + fill_size, fill);
|
||||
}
|
||||
std::ptrdiff_t offset = get(prepare_int_buffer(
|
||||
num_digits, subspec, prefix, prefix_size)) - &buffer_[0];
|
||||
CharPtr result = prepare_int_buffer(
|
||||
num_digits, subspec, prefix, prefix_size);
|
||||
if (align == ALIGN_LEFT) {
|
||||
CharPtr p = grow_buffer(fill_size);
|
||||
std::uninitialized_fill(p, p + fill_size, fill);
|
||||
}
|
||||
return internal::make_ptr(&buffer_[0], buffer_.size()) + offset;
|
||||
return result;
|
||||
}
|
||||
unsigned size = prefix_size + num_digits;
|
||||
if (width <= size) {
|
||||
@@ -3149,7 +3078,7 @@ void BasicWriter<Char>::write_int(T value, Spec spec) {
|
||||
case 'n': {
|
||||
unsigned num_digits = internal::count_digits(abs_value);
|
||||
fmt::StringRef sep = "";
|
||||
#if !defined(__ANDROID__) && !defined(UNDER_CE)
|
||||
#if !(defined(ANDROID) || defined(__ANDROID__))
|
||||
sep = internal::thousands_sep(std::localeconv());
|
||||
#endif
|
||||
unsigned size = static_cast<unsigned>(
|
||||
@@ -3354,10 +3283,10 @@ void BasicWriter<Char>::write_double(T value, const Spec &spec) {
|
||||
accessed as a C string with ``out.c_str()``.
|
||||
\endrst
|
||||
*/
|
||||
template <typename Char, typename Allocator = std::allocator<Char>, std::size_t INLINE_BUFFER_SIZE = internal::INLINE_BUFFER_SIZE>
|
||||
template <typename Char, typename Allocator = std::allocator<Char> >
|
||||
class BasicMemoryWriter : public BasicWriter<Char> {
|
||||
private:
|
||||
internal::MemoryBuffer<Char, INLINE_BUFFER_SIZE, Allocator> buffer_;
|
||||
internal::MemoryBuffer<Char, internal::INLINE_BUFFER_SIZE, Allocator> buffer_;
|
||||
|
||||
public:
|
||||
explicit BasicMemoryWriter(const Allocator& alloc = Allocator())
|
||||
@@ -4123,8 +4052,7 @@ ArgJoin<wchar_t, It> join(It first, It last, const BasicCStringRef<wchar_t>& sep
|
||||
return ArgJoin<wchar_t, It>(first, last, sep);
|
||||
}
|
||||
|
||||
#if FMT_HAS_GXX_CXX11 && \
|
||||
(!FMT_GCC_VERSION || FMT_GCC_VERSION >= 405 || __clang__)
|
||||
#if FMT_HAS_GXX_CXX11
|
||||
template <typename Range>
|
||||
auto join(const Range& range, const BasicCStringRef<char>& sep)
|
||||
-> ArgJoin<char, decltype(std::begin(range))> {
|
||||
@@ -4142,14 +4070,10 @@ template <typename ArgFormatter, typename Char, typename It>
|
||||
void format_arg(fmt::BasicFormatter<Char, ArgFormatter> &f,
|
||||
const Char *&format_str, const ArgJoin<Char, It>& e) {
|
||||
const Char* end = format_str;
|
||||
int brace_level = 1;
|
||||
while (*end) {
|
||||
if (*end == '}' && --brace_level == 0)
|
||||
break;
|
||||
if (*end == '{')
|
||||
++brace_level;
|
||||
if (*end == ':')
|
||||
++end;
|
||||
while (*end && *end != '}')
|
||||
++end;
|
||||
}
|
||||
if (*end != '}')
|
||||
FMT_THROW(FormatError("missing '}' in format string"));
|
||||
|
||||
@@ -4246,9 +4170,4 @@ operator"" _a(const wchar_t *s, std::size_t) { return {s}; }
|
||||
# define FMT_FUNC
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma warn .8072 // restore "suspicious pointer arithmetic" warning on access of the digits array
|
||||
#pragma warn .8004 // restore "assigned value that is never used" warning
|
||||
#endif
|
||||
|
||||
#endif // FMT_FORMAT_H_
|
||||
|
||||
@@ -64,7 +64,6 @@ template <typename T>
|
||||
struct ConvertToIntImpl<T, true> {
|
||||
// Convert to int only if T doesn't have an overloaded operator<<.
|
||||
enum {
|
||||
#pragma warning(suppress: 4244)
|
||||
value = sizeof(convert(get<DummyStream>() << get<T>())) == sizeof(No)
|
||||
};
|
||||
};
|
||||
|
||||
15
fmt/posix.cc
15
fmt/posix.cc
@@ -26,13 +26,10 @@
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# include <io.h>
|
||||
#include <algorithm>
|
||||
# ifndef O_CREAT
|
||||
# define O_CREAT _O_CREAT
|
||||
# endif
|
||||
# ifndef O_TRUNC
|
||||
# define O_TRUNC _O_TRUNC
|
||||
# endif
|
||||
|
||||
# define O_CREAT _O_CREAT
|
||||
# define O_TRUNC _O_TRUNC
|
||||
|
||||
# ifndef S_IRUSR
|
||||
# define S_IRUSR _S_IREAD
|
||||
# endif
|
||||
@@ -59,7 +56,7 @@ typedef int RWResult;
|
||||
// On Windows the count argument to read and write is unsigned, so convert
|
||||
// it from size_t preventing integer overflow.
|
||||
inline unsigned convert_rwcount(std::size_t count) {
|
||||
return static_cast<unsigned>(std::min<std::size_t>(count, UINT_MAX));
|
||||
return count <= UINT_MAX ? static_cast<unsigned>(count) : UINT_MAX;
|
||||
}
|
||||
#else
|
||||
// Return type of read and write functions.
|
||||
@@ -102,7 +99,7 @@ int fmt::BufferedFile::fileno() const {
|
||||
|
||||
fmt::File::File(fmt::CStringRef path, int oflag) {
|
||||
int mode = S_IRUSR | S_IWUSR;
|
||||
#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__BORLANDC__)
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
fd_ = -1;
|
||||
FMT_POSIX_CALL(sopen_s(&fd_, path.c_str(), oflag, _SH_DENYNO, mode));
|
||||
#else
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
#ifndef FMT_POSIX_H_
|
||||
#define FMT_POSIX_H_
|
||||
|
||||
#if defined(__MINGW32__) || defined(__CYGWIN__)
|
||||
// Workaround MinGW bug https://sourceforge.net/p/mingw/bugs/2024/.
|
||||
# undef __STRICT_ANSI__
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h> // for O_RDONLY
|
||||
#include <locale.h> // for locale_t
|
||||
@@ -41,10 +46,6 @@
|
||||
# ifdef _WIN32
|
||||
// Fix warnings about deprecated symbols.
|
||||
# define FMT_POSIX_CALL(call) ::_##call
|
||||
# if defined(__BORLANDC__) && !defined(_dup2)
|
||||
// for some reason the borland headers do define _dup but not _dup2
|
||||
# define _dup2 dup2
|
||||
# endif
|
||||
# else
|
||||
# define FMT_POSIX_CALL(call) ::call
|
||||
# endif
|
||||
|
||||
@@ -333,7 +333,7 @@ class PrintfFormatter : private internal::FormatterBase {
|
||||
\endrst
|
||||
*/
|
||||
explicit PrintfFormatter(const ArgList &al, BasicWriter<Char> &w)
|
||||
: internal::FormatterBase(al), writer_(w) {}
|
||||
: FormatterBase(al), writer_(w) {}
|
||||
|
||||
/** Formats stored arguments and writes the output to the writer. */
|
||||
void format(BasicCStringRef<Char> format_str);
|
||||
@@ -371,7 +371,7 @@ internal::Arg PrintfFormatter<Char, AF>::get_arg(const Char *s,
|
||||
(void)s;
|
||||
const char *error = FMT_NULL;
|
||||
internal::Arg arg = arg_index == std::numeric_limits<unsigned>::max() ?
|
||||
next_arg(error) : internal::FormatterBase::get_arg(arg_index - 1, error);
|
||||
next_arg(error) : FormatterBase::get_arg(arg_index - 1, error);
|
||||
if (error)
|
||||
FMT_THROW(FormatError(!*s ? "invalid format string" : error));
|
||||
return arg;
|
||||
|
||||
@@ -2,5 +2,3 @@ This directory contains build support files such as
|
||||
|
||||
* CMake modules
|
||||
* Build scripts
|
||||
* qmake (static build with dynamic libc only)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ build = os.environ['BUILD']
|
||||
config = os.environ['CONFIGURATION']
|
||||
platform = os.environ.get('PLATFORM')
|
||||
path = os.environ['PATH']
|
||||
cmake_command = ['cmake', '-DFMT_PEDANTIC=ON', '-DCMAKE_BUILD_TYPE=' + config, '.']
|
||||
cmake_command = ['cmake', '-DFMT_PEDANTIC=ON', '-DCMAKE_BUILD_TYPE=' + config]
|
||||
if build == 'mingw':
|
||||
cmake_command.append('-GMinGW Makefiles')
|
||||
build_command = ['mingw32-make', '-j4']
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
# Staticlib configuration for qmake builds
|
||||
# For some reason qmake 3.1 fails to identify source dependencies and excludes format.cc and printf.cc
|
||||
# from compilation so it _MUST_ be called as qmake -nodepend
|
||||
# A workaround is implemented below: a custom compiler is defined which does not track dependencies
|
||||
|
||||
TEMPLATE = lib
|
||||
|
||||
TARGET = fmt
|
||||
|
||||
QMAKE_EXT_CPP = .cc
|
||||
|
||||
CONFIG = staticlib warn_on c++11
|
||||
|
||||
FMT_SOURCES = \
|
||||
../fmt/format.cc \
|
||||
../fmt/ostream.cc \
|
||||
../fmt/posix.cc \
|
||||
../fmt/printf.cc
|
||||
|
||||
fmt.name = libfmt
|
||||
fmt.input = FMT_SOURCES
|
||||
fmt.output = ${QMAKE_FILE_BASE}$$QMAKE_EXT_OBJ
|
||||
fmt.clean = ${QMAKE_FILE_BASE}$$QMAKE_EXT_OBJ
|
||||
fmt.depends = ${QMAKE_FILE_IN}
|
||||
# QMAKE_RUN_CXX will not be expanded
|
||||
fmt.commands = $$QMAKE_CXX -c $$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_WARN_ON $$QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO $$QMAKE_CXXFLAGS_CXX11 ${QMAKE_FILE_IN}
|
||||
fmt.variable_out = OBJECTS
|
||||
fmt.CONFIG = no_dependencies no_link
|
||||
QMAKE_EXTRA_COMPILERS += fmt
|
||||
@@ -141,7 +141,6 @@ def update_site(env):
|
||||
b.data = re.sub(pattern, r'doxygenfunction:: \1(int)', b.data)
|
||||
b.data = b.data.replace('std::FILE*', 'std::FILE *')
|
||||
b.data = b.data.replace('unsigned int', 'unsigned')
|
||||
b.data = b.data.replace('operator""_', 'operator"" _')
|
||||
# Fix a broken link in index.rst.
|
||||
index = os.path.join(target_doc_dir, 'index.rst')
|
||||
with rewrite(index) as b:
|
||||
|
||||
@@ -11,12 +11,6 @@ target_compile_options(gmock PUBLIC ${CPP11_FLAG})
|
||||
target_compile_definitions(gmock PUBLIC GTEST_HAS_STD_WSTRING=1)
|
||||
target_include_directories(gmock PUBLIC .)
|
||||
|
||||
# Workaround for Cygwin to make google-tests compile and run because the macro
|
||||
# _POSIX_C_SOURCE must be defined to allow fileno(), strdup(), fdopen() calls.
|
||||
if (CYGWIN)
|
||||
target_compile_definitions(gmock PUBLIC _POSIX_C_SOURCE=200809)
|
||||
endif ()
|
||||
|
||||
find_package(Threads)
|
||||
if (Threads_FOUND)
|
||||
target_link_libraries(gmock ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
@@ -156,11 +156,6 @@ TEST(StringRefTest, Ctor) {
|
||||
EXPECT_STREQ("hijk", StringRef(std::string_view("hijk")).data());
|
||||
EXPECT_EQ(4u, StringRef(std::string_view("hijk")).size());
|
||||
#endif
|
||||
|
||||
#if FMT_HAS_EXPERIMENTAL_STRING_VIEW
|
||||
EXPECT_STREQ("hijk", StringRef(std::experimental::string_view("hijk")).data());
|
||||
EXPECT_EQ(4u, StringRef(std::experimental::string_view("hijk")).size());
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(StringRefTest, ConvertToString) {
|
||||
@@ -172,12 +167,6 @@ TEST(StringRefTest, ConvertToString) {
|
||||
std::string_view sv = static_cast<std::string_view>(str_ref);
|
||||
EXPECT_EQ("defg", sv);
|
||||
#endif
|
||||
|
||||
#if FMT_HAS_EXPERIMENTAL_STRING_VIEW
|
||||
StringRef str_ref("defg");
|
||||
std::experimental::string_view sv = static_cast<std::experimental::string_view>(str_ref);
|
||||
EXPECT_EQ("defg", sv);
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(CStringRefTest, Ctor) {
|
||||
@@ -187,10 +176,6 @@ TEST(CStringRefTest, Ctor) {
|
||||
#if FMT_HAS_STRING_VIEW
|
||||
EXPECT_STREQ("hijk", CStringRef(std::string_view("hijk")).c_str());
|
||||
#endif
|
||||
|
||||
#if FMT_HAS_EXPERIMENTAL_STRING_VIEW
|
||||
EXPECT_STREQ("hijk", CStringRef(std::experimental::string_view("hijk")).c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
#if FMT_USE_TYPE_TRAITS
|
||||
@@ -1414,12 +1399,6 @@ TEST(FormatterTest, FormatStringView) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if FMT_HAS_EXPERIMENTAL_STRING_VIEW
|
||||
TEST(FormatterTest, FormatExperimentalStringView) {
|
||||
EXPECT_EQ("test", format("{0}", std::experimental::string_view("test")));
|
||||
}
|
||||
#endif
|
||||
|
||||
void format_arg(fmt::BasicFormatter<char> &f, const char *, const Date &d) {
|
||||
f.writer() << d.year() << '-' << d.month() << '-' << d.day();
|
||||
}
|
||||
@@ -1611,15 +1590,13 @@ TEST(FormatTest, JoinArg) {
|
||||
v2.push_back(1.2f);
|
||||
v2.push_back(3.4f);
|
||||
|
||||
EXPECT_EQ("(1, 2, 3)", format("({})", join(v1, v1 + 3, ", ")));
|
||||
EXPECT_EQ("(1)", format("({})", join(v1, v1 + 1, ", ")));
|
||||
EXPECT_EQ("()", format("({})", join(v1, v1, ", ")));
|
||||
EXPECT_EQ("(001, 002, 003)", format("({:03})", join(v1, v1 + 3, ", ")));
|
||||
EXPECT_EQ("(+01.20, +03.40)",
|
||||
format("({:+06.2f})", join(v2.begin(), v2.end(), ", ")));
|
||||
EXPECT_EQ("(1, 2, 3)", format("({})", join(v1 + 0, v1 + 3, ", ")));
|
||||
EXPECT_EQ("(1)", format("({})", join(v1 + 0, v1 + 1, ", ")));
|
||||
EXPECT_EQ("()", format("({})", join(v1 + 0, v1 + 0, ", ")));
|
||||
EXPECT_EQ("(001, 002, 003)", format("({:03})", join(v1 + 0, v1 + 3, ", ")));
|
||||
EXPECT_EQ("(+01.20, +03.40)", format("({:+06.2f})", join(v2.begin(), v2.end(), ", ")));
|
||||
|
||||
EXPECT_EQ(L"(1, 2, 3)", format(L"({})", join(v1, v1 + 3, L", ")));
|
||||
EXPECT_EQ("1, 2, 3", format("{0:{1}}", join(v1, v1 + 3, ", "), 1));
|
||||
EXPECT_EQ(L"(1, 2, 3)", format(L"({})", join(v1 + 0, v1 + 3, L", ")));
|
||||
|
||||
#if FMT_HAS_GXX_CXX11
|
||||
EXPECT_EQ("(1, 2, 3)", format("({})", join(v1, ", ")));
|
||||
@@ -1761,7 +1738,3 @@ void convert(int);
|
||||
TEST(FormatTest, ConvertCollision) {
|
||||
fmt::format("{}", 42);
|
||||
}
|
||||
|
||||
TEST(FormatTest, Regression) {
|
||||
fmt::format("...........{:<77777.7p}", "foo");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user