Skip to content

Commit

Permalink
constrain templated format_to on proper format string type.
Browse files Browse the repository at this point in the history
Signed-off-by: Daniela Engert <[email protected]>
  • Loading branch information
DanielaE authored and vitaut committed Sep 27, 2018
1 parent d7f1761 commit 4cf21f5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 0 additions & 4 deletions include/fmt/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,6 @@ 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
3 changes: 3 additions & 0 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,9 @@ 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::is_empty<format_string_traits<S>> {};

template <typename S>
struct is_compile_string :
std::integral_constant<bool, std::is_base_of<compile_string, S>::value> {};
Expand Down
3 changes: 2 additions & 1 deletion include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -3507,7 +3507,8 @@ inline OutputIt vformat_to(
\endrst
*/
template <typename OutputIt, typename String, typename... Args>
inline OutputIt format_to(OutputIt out, const String &format_str,
inline typename std::enable_if<internal::is_format_string<String>::value, OutputIt>::type
format_to(OutputIt out, const String &format_str,
const Args &... args) {
internal::check_format_string<Args...>(format_str);
typedef typename format_context_t<OutputIt, FMT_CHAR(String) >::type context_t;
Expand Down

0 comments on commit 4cf21f5

Please sign in to comment.