Commit 699fe8e7 authored by Jack Andersen's avatar Jack Andersen Committed by Victor Zverovich

Remove const qualification in compile-time checks

parent da2d33f1
......@@ -198,6 +198,8 @@ using conditional_t = typename std::conditional<B, T, F>::type;
template <bool B> using bool_constant = std::integral_constant<bool, B>;
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;
struct monostate {};
......@@ -1273,7 +1275,7 @@ make_args_checked(const S& format_str,
static_assert(all_true<(!std::is_base_of<view, remove_reference_t<Args>>() ||
!std::is_reference<Args>())...>::value,
"passing views as lvalues is disallowed");
check_format_string<remove_reference_t<Args>...>(format_str);
check_format_string<remove_const_t<remove_reference_t<Args>>...>(format_str);
return {args...};
}
......
......@@ -1854,6 +1854,14 @@ TEST(FormatTest, CompileTimeString) {
EXPECT_EQ("foo", fmt::format(FMT_STRING("{}"), string_like()));
}
TEST(FormatTest, CustomFormatCompileTimeString) {
EXPECT_EQ("42", fmt::format(FMT_STRING("{}"), Answer()));
Answer answer;
EXPECT_EQ("42", fmt::format(FMT_STRING("{}"), answer));
const Answer const_answer;
EXPECT_EQ("42", fmt::format(FMT_STRING("{}"), const_answer));
}
#if FMT_USE_USER_DEFINED_LITERALS
// Passing user-defined literals directly to EXPECT_EQ causes problems
// with macro argument stringification (#) on some versions of GCC.
......
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