mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-25 15:21:54 +00:00
Add specialization test
This commit is contained in:
parent
946498cfbc
commit
5efb24dd2b
@ -112,9 +112,11 @@ struct fallback_formatter<
|
|||||||
|
|
||||||
// Disable conversion to int if T has an overloaded operator<< which is a free
|
// Disable conversion to int if T has an overloaded operator<< which is a free
|
||||||
// function (not a member of std::ostream).
|
// function (not a member of std::ostream).
|
||||||
template <typename T, typename Char> struct convert_to_int<T, Char, void> {
|
template <typename T, typename Char>
|
||||||
static const bool value = convert_to_int<T, Char, int>::value &&
|
struct convert_to_int<
|
||||||
!internal::is_streamable<T, Char>::value;
|
T, Char,
|
||||||
|
typename std::enable_if<internal::is_streamable<T, Char>::value>::type> {
|
||||||
|
static const bool value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
|
@ -6,6 +6,21 @@
|
|||||||
// For the license information refer to format.h.
|
// For the license information refer to format.h.
|
||||||
|
|
||||||
#define FMT_STRING_ALIAS 1
|
#define FMT_STRING_ALIAS 1
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
|
struct test {};
|
||||||
|
|
||||||
|
// Test that there is no issues with specializations when fmt/ostream.h is
|
||||||
|
// included after fmt/format.h.
|
||||||
|
namespace fmt {
|
||||||
|
template <> struct formatter<test> : formatter<int> {
|
||||||
|
template <typename FormatContext>
|
||||||
|
typename FormatContext::iterator format(const test&, FormatContext& ctx) {
|
||||||
|
return formatter<int>::format(42, ctx);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace fmt
|
||||||
|
|
||||||
#include "fmt/ostream.h"
|
#include "fmt/ostream.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
Loading…
Reference in New Issue
Block a user