Fix compile-time checks for user-defined types (#1292)
This commit is contained in:
parent
d1dd9d5327
commit
422e7b9d70
@ -207,6 +207,8 @@ template <typename T>
|
||||
using remove_reference_t = typename std::remove_reference<T>::type;
|
||||
template <typename T>
|
||||
using remove_const_t = typename std::remove_const<T>::type;
|
||||
template <typename T>
|
||||
using remove_cvref_t = typename std::remove_cv<remove_reference_t<T>>::type;
|
||||
|
||||
struct monostate {};
|
||||
|
||||
|
@ -3466,7 +3466,7 @@ template <typename Char, Char... CHARS> class udl_formatter {
|
||||
std::basic_string<Char> operator()(Args&&... args) const {
|
||||
FMT_CONSTEXPR_DECL Char s[] = {CHARS..., '\0'};
|
||||
FMT_CONSTEXPR_DECL bool invalid_format =
|
||||
do_check_format_string<Char, error_handler, Args...>(
|
||||
do_check_format_string<Char, error_handler, remove_cvref_t<Args>...>(
|
||||
basic_string_view<Char>(s, sizeof...(CHARS)));
|
||||
(void)invalid_format;
|
||||
return format(s, std::forward<Args>(args)...);
|
||||
|
@ -1894,6 +1894,11 @@ TEST(FormatTest, UdlTemplate) {
|
||||
EXPECT_EQ("foo", "foo"_format());
|
||||
EXPECT_EQ(" 42", "{0:10}"_format(42));
|
||||
}
|
||||
|
||||
TEST(FormatTest, UdlPassUserDefinedObjectAsLvalue) {
|
||||
Date date(2015, 10, 21);
|
||||
EXPECT_EQ("2015-10-21", "{}"_format(date));
|
||||
}
|
||||
#endif // FMT_USE_USER_DEFINED_LITERALS
|
||||
|
||||
enum TestEnum { A };
|
||||
|
Loading…
Reference in New Issue
Block a user