Skip to content

Commit

Permalink
Fix GCC 9.4.0 compilation error
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiud committed Jan 20, 2025
1 parent aabe639 commit c74801b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
16 changes: 16 additions & 0 deletions include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@
# define FMT_OPTIMIZE_SIZE 0
#endif

// libc++ supports string_view in pre-c++17.
#if FMT_HAS_INCLUDE(<string_view>) && \
(FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION))
# include <string_view>
# define FMT_USE_STRING_VIEW
#endif

// FMT_BUILTIN_TYPE=0 may result in smaller library size at the cost of higher
// per-call binary size by passing built-in types through the extension API.
#ifndef FMT_BUILTIN_TYPES
Expand Down Expand Up @@ -503,6 +510,11 @@ inline FMT_CONSTEXPR20 auto get_container(OutputIt it) ->
};
return *accessor(it).container;
}

#if !defined(FMT_USE_STRING_VIEW)
template <class Ch> struct std_string_view;
#endif

} // namespace detail

// Parsing-related public API and forward declarations.
Expand Down Expand Up @@ -556,6 +568,10 @@ template <typename Char> class basic_string_view {
FMT_CONSTEXPR basic_string_view(const S& s) noexcept
: data_(s.data()), size_(s.size()) {}

#if !defined(FMT_USE_STRING_VIEW)
FMT_CONSTEXPR basic_string_view(detail::std_string_view<Char> /*s*/) {}
#endif

/// Returns a pointer to the string data.
constexpr auto data() const noexcept -> const Char* { return data_; }

Expand Down
7 changes: 0 additions & 7 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@
# include <bit> // std::bit_cast
# endif

// libc++ supports string_view in pre-c++17.
# if FMT_HAS_INCLUDE(<string_view>) && \
(FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION))
# include <string_view>
# define FMT_USE_STRING_VIEW
# endif

# if FMT_MSC_VERSION
# include <intrin.h> // _BitScanReverse[64], _umul128
# endif
Expand Down

0 comments on commit c74801b

Please sign in to comment.