Commit 422e7b9d authored by Victor Zverovich's avatar Victor Zverovich

Fix compile-time checks for user-defined types (#1292)

parent d1dd9d53
......@@ -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 };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment