From c85d5e342c2386ae487eec3468ea595d286ffabb Mon Sep 17 00:00:00 2001 From: Walter Gray Date: Sun, 20 Dec 2020 16:07:45 -0800 Subject: [PATCH] address easy comments --- include/fmt/chrono.h | 1 - include/fmt/core.h | 1 - test/CMakeLists.txt | 2 +- test/enforce-compile-string-test.cc | 32 ++++++----------------------- 4 files changed, 7 insertions(+), 29 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 417ff992..d5c9d641 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -769,7 +769,6 @@ template ::value)> OutputIt format_duration_value(OutputIt out, Rep val, int) { static FMT_CONSTEXPR_DECL const Char format[] = {'{', '}', 0}; - return vformat_to(out, to_string_view(format), make_format_args>(val)); } diff --git a/include/fmt/core.h b/include/fmt/core.h index f96ce3a1..d7d2de50 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1841,7 +1841,6 @@ inline auto format_to_n(OutputIt out, size_t n, const S& format_str, Returns the number of characters in the output of ``format(format_str, args...)``. */ - template inline size_t formatted_size(string_view format_str, Args&&... args) { const auto& vargs = fmt::make_args_checked(format_str, args...); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f34a71ee..78798d87 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -106,7 +106,7 @@ add_fmt_test(printf-test) add_fmt_test(ranges-test) add_fmt_test(scan-test) -if(NOT MSVC) +if (NOT MSVC) # FMT_ENFORCE_COMPILE_STRING not supported under MSVC # See https://developercommunity.visualstudio.com/content/problem/1277597/internal-compiler-c0001-error-on-complex-nested-la.html add_fmt_test(enforce-compile-string-test) diff --git a/test/enforce-compile-string-test.cc b/test/enforce-compile-string-test.cc index 5573f59c..f1e8edee 100644 --- a/test/enforce-compile-string-test.cc +++ b/test/enforce-compile-string-test.cc @@ -6,13 +6,10 @@ // For the license information refer to format.h. #include +#include #include #include -#include -#include #include -#include -#include #include "fmt/chrono.h" #include "fmt/color.h" @@ -25,10 +22,7 @@ void test_format_api() { (void)fmt::format(FMT_STRING("{}"), 42); (void)fmt::format(FMT_STRING(L"{}"), 42); -#if !FMT_GCC_VERSION // Currently will not compile: See - // https://github.com/fmtlib/fmt/issues/2039 (void)fmt::format(FMT_STRING("noop")); -#endif (void)fmt::to_string(42); (void)fmt::to_wstring(42); @@ -46,11 +40,8 @@ void test_format_api() { void test_literals_api() { #if FMT_USE_UDL_TEMPLATE using namespace fmt::literals; - - auto udl_format = "{}c{}"_format("ab", 1); - auto udl_format_w = L"{}c{}"_format(L"ab", 1); - (void)udl_format; - (void)udl_format_w; + "{}c{}"_format("ab", 1); + L"{}c{}"_format(L"ab", 1); #endif } @@ -70,19 +61,8 @@ void test_text_style() { FMT_STRING("rgb(255,20,30){}{}{}"), 1, 2, 3); } -struct zstring_sentinel {}; - -bool operator==(const char* p, zstring_sentinel) { return *p == '\0'; } -bool operator!=(const char* p, zstring_sentinel) { return *p != '\0'; } - -struct zstring { - const char* p; - const char* begin() const { return p; } - zstring_sentinel end() const { return {}; } -}; - -void test_zstring() { - zstring hello{"hello"}; +void test_range() { + std::array hello = {'h','e','l','l','o'}; (void)fmt::format(FMT_STRING("{}"), hello); } @@ -91,5 +71,5 @@ int main() { test_literals_api(); test_chrono(); test_text_style(); - test_zstring(); + test_range(); }