mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-22 10:30:05 +00:00
Remove const qualification in compile-time checks
This commit is contained in:
parent
da2d33f1f1
commit
699fe8e711
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user