Skip to content

Commit

Permalink
Fix collision with global convert function (#425)
Browse files Browse the repository at this point in the history
(cherry picked from commit 796beaa)
  • Loading branch information
vitaut authored and foonathan committed Jun 8, 2017
1 parent baedba0 commit a55df13
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,9 @@ struct ConvertToIntImpl2<T, true> {

template<typename T>
struct ConvertToInt {
enum { enable_conversion = sizeof(convert(get<T>())) == sizeof(Yes) };
enum {
enable_conversion = sizeof(fmt::internal::convert(get<T>())) == sizeof(Yes)
};
enum { value = ConvertToIntImpl2<T, enable_conversion>::value };
};

Expand Down
8 changes: 8 additions & 0 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1653,3 +1653,11 @@ FMT_VARIADIC(void, custom_format, const char *)
TEST(FormatTest, CustomArgFormatter) {
custom_format("{}", 42);
}

void convert(int);

// Check if there is no collision with convert function in the global namespace.
TEST(FormatTest, ConvertCollision) {
fmt::format("{}", 42);
}

0 comments on commit a55df13

Please sign in to comment.