diff --git a/CMakeLists.txt b/CMakeLists.txt index 84db4c84..89129617 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,17 +176,17 @@ target_include_directories(fmt PUBLIC set(FMT_DEBUG_POSTFIX d) +set(FMT_DEBUG_POSTFIX d) + set_target_properties(fmt PROPERTIES - OUTPUT_NAME fmt - VERSION ${FMT_VERSION} - SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR} + VERSION ${FMT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR} DEBUG_POSTFIX ${FMT_DEBUG_POSTFIX}) -# Configure pkg-config fmt.pc properly +# Set FMT_LIB_NAME for pkg-config fmt.pc. get_target_property(FMT_LIB_NAME fmt OUTPUT_NAME) -if(CMAKE_BUILD_TYPE STREQUAL "Debug") +if (CMAKE_BUILD_TYPE STREQUAL "Debug") set(FMT_LIB_NAME ${FMT_LIB_NAME}${FMT_DEBUG_POSTFIX}) -endif() +endif () if (BUILD_SHARED_LIBS) if (UNIX AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS") diff --git a/README.rst b/README.rst index 34427826..af9f9252 100644 --- a/README.rst +++ b/README.rst @@ -33,7 +33,7 @@ Features * Safe `printf implementation `_ including the POSIX extension for positional arguments. -* Implementation of `C++20 std::format `__. +* Implementation of `C++20 std::format `__. * Support for user-defined types. * High performance: faster than common standard library implementations of `printf `_ and diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 80cbe697..421d464a 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -495,12 +495,12 @@ FMT_CONSTEXPR const Char* parse_chrono_format(const Char* begin, handler.on_text(ptr - 1, ptr); break; case 'n': { - const Char newline[]{'\n', 0}; + const Char newline[] = {'\n'}; handler.on_text(newline, newline + 1); break; } case 't': { - const Char tab[]{'\t', 0}; + const Char tab[] = {'\t'}; handler.on_text(tab, tab + 1); break; } @@ -761,10 +761,10 @@ inline std::chrono::duration get_milliseconds( template OutputIt format_duration_value(OutputIt out, Rep val, int precision) { - const Char pr_f[]{'{', ':', '.', '{', '}', 'f', '}', 0}; + const Char pr_f[] = {'{', ':', '.', '{', '}', 'f', '}', 0}; if (precision >= 0) return format_to(out, pr_f, val, precision); - const Char fp_f[]{'{', ':', 'g', '}', 0}; - const Char format[]{'{', '}', 0}; + const Char fp_f[] = {'{', ':', 'g', '}', 0}; + const Char format[] = {'{', '}', 0}; return format_to(out, std::is_floating_point::value ? fp_f : format, val); } @@ -779,9 +779,9 @@ OutputIt format_duration_unit(OutputIt out) { } return std::copy(s.begin(), s.end(), out); } - const Char num_f[]{'[', '{', '}', ']', 's', 0}; + const Char num_f[] = {'[', '{', '}', ']', 's', 0}; if (Period::den == 1) return format_to(out, num_f, Period::num); - const Char num_def_f[]{'[', '{', '}', '/', '{', '}', ']', 's', 0}; + const Char num_def_f[] = {'[', '{', '}', '/', '{', '}', ']', 's', 0}; return format_to(out, num_def_f, Period::num, Period::den); } diff --git a/include/fmt/core.h b/include/fmt/core.h index 5aefcc14..6824c125 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -185,11 +185,20 @@ # define FMT_CLASS_API #endif #ifndef FMT_API -# define FMT_API +# if FMT_GCC_VERSION || FMT_CLANG_VERSION +# define FMT_API __attribute__((visibility("default"))) +# define FMT_EXTERN_TEMPLATE_API FMT_API +# define FMT_INSTANTIATION_DEF_API +# else +# define FMT_API +# endif #endif #ifndef FMT_EXTERN_TEMPLATE_API # define FMT_EXTERN_TEMPLATE_API #endif +#ifndef FMT_INSTANTIATION_DEF_API +# define FMT_INSTANTIATION_DEF_API FMT_API +#endif #ifndef FMT_HEADER_ONLY # define FMT_EXTERN extern @@ -304,7 +313,8 @@ template class basic_string_view { size_t size_; public: - using char_type = Char; + using char_type FMT_DEPRECATED_ALIAS = Char; + using value_type = Char; using iterator = const Char*; FMT_CONSTEXPR basic_string_view() FMT_NOEXCEPT : data_(nullptr), size_(0) {} @@ -462,7 +472,7 @@ struct is_string : std::is_class()))> { template struct char_t_impl {}; template struct char_t_impl::value>> { using result = decltype(to_string_view(std::declval())); - using type = typename result::char_type; + using type = typename result::value_type; }; struct error_handler { diff --git a/src/format.cc b/src/format.cc index e6fde7c3..9a9abf8d 100644 --- a/src/format.cc +++ b/src/format.cc @@ -121,7 +121,7 @@ template FMT_API char* internal::sprintf_format(long double, internal::buffer&, sprintf_specs); -template struct FMT_API internal::basic_data; +template struct FMT_INSTANTIATION_DEF_API internal::basic_data; // Workaround a bug in MSVC2013 that prevents instantiation of format_float. int (*instantiate_format_float)(double, int, internal::float_specs, diff --git a/test/core-test.cc b/test/core-test.cc index 08f27024..8f233ece 100644 --- a/test/core-test.cc +++ b/test/core-test.cc @@ -402,8 +402,12 @@ TEST(ArgTest, VisitInvalidArg) { fmt::visit_format_arg(visitor, arg); } +TEST(StringViewTest, ValueType) { + static_assert(std::is_same::value, ""); +} + TEST(StringViewTest, Length) { - // Test that StringRef::size() returns string length, not buffer size. + // Test that string_view::size() returns string length, not buffer size. char str[100] = "some string"; EXPECT_EQ(std::strlen(str), string_view(str).size()); EXPECT_LT(std::strlen(str), sizeof(str));