Skip to content

Commit

Permalink
Implement workarounds for gcc 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Sep 23, 2018
1 parent 0ea3221 commit 48e6dcd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
4 changes: 4 additions & 0 deletions include/fmt/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ template <>
inline void reset_color<wchar_t>(FILE *stream) FMT_NOEXCEPT {
fputs(internal::data::WRESET_COLOR, stream);
}

template <typename S>
struct is_format_string: std::integral_constant<
bool, std::is_empty<format_string_traits<S>>::value> {};
} // namespace internal

template <
Expand Down
26 changes: 14 additions & 12 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ FMT_CONSTEXPR size_t length(const Char *s) {
FMT_CONSTEXPR size_t length(const char *s) { return std::strlen(s); }
#endif

#if FMT_GCC_VERSION && FMT_GCC_VERSION < 405
template <typename... T>
struct is_constructible: std::false_type {};
#else
template <typename... T>
struct is_constructible: std::is_constructible<T...> {};
#endif

template <typename T>
struct no_formatter_error : std::false_type {};
} // namespace internal
Expand Down Expand Up @@ -644,15 +652,15 @@ inline typename std::enable_if<

template <typename C, typename T, typename Char = typename C::char_type>
inline typename std::enable_if<
std::is_constructible<basic_string_view<Char>, T>::value,
internal::is_constructible<basic_string_view<Char>, T>::value,
init<C, basic_string_view<Char>, string_type>>::type
make_value(const T &val) { return basic_string_view<Char>(val); }

template <typename C, typename T, typename Char = typename C::char_type>
inline typename std::enable_if<
!convert_to_int<T, Char>::value &&
!std::is_convertible<T, basic_string_view<Char>>::value &&
!std::is_constructible<basic_string_view<Char>, T>::value,
!internal::is_constructible<basic_string_view<Char>, T>::value,
// Implicit conversion to std::string is not handled here because it's
// unsafe: https://github.com/fmtlib/fmt/issues/729
init<C, const T &, custom_type>>::type
Expand Down Expand Up @@ -1253,11 +1261,10 @@ namespace internal {
// If S is a format string type, format_string_traints<S>::char_type gives its
// character type.
template <typename S, typename Enable = void>
struct format_string_traits {
private:
// Use constructability as a way to detect if format_string_traits is
// specialized because other methods are broken on MSVC2013.
format_string_traits();
class format_string_traits {
// Use emptyness as a way to detect if format_string_traits is
// specialized because other methods are broken on MSVC2013 or gcc 4.4.
int dummy;
};

template <typename Char>
Expand Down Expand Up @@ -1285,11 +1292,6 @@ struct format_string_traits<
basic_string_view<typename S::char_type>, S>::value>::type> :
format_string_traits_base<typename S::char_type> {};

template <typename S>
struct is_format_string :
std::integral_constant<
bool, std::is_constructible<format_string_traits<S>>::value> {};

template <typename S>
struct is_compile_string :
std::integral_constant<bool, std::is_base_of<compile_string, S>::value> {};
Expand Down

0 comments on commit 48e6dcd

Please sign in to comment.