Make const-correct
This commit is contained in:
parent
ef3ffef853
commit
5e9dfa354c
@ -678,9 +678,9 @@ struct formatter<T, Char,
|
||||
enable_if_t<detail::is_container_adaptor_like<T>::value>>
|
||||
: formatter<typename T::container_type, Char> {
|
||||
template <typename FormatContext>
|
||||
auto format(T& t, FormatContext& ctx) const -> decltype(ctx.out()) {
|
||||
auto format(const T& t, FormatContext& ctx) const -> decltype(ctx.out()) {
|
||||
struct getter : T {
|
||||
static auto get(T& t) -> typename T::container_type& {
|
||||
static auto get(const T& t) -> const typename T::container_type& {
|
||||
return t.*(&getter::c); // Access c through the derived class.
|
||||
}
|
||||
};
|
||||
|
||||
@ -424,6 +424,7 @@ TEST(ranges_test, container_adaptor) {
|
||||
s.push(1);
|
||||
s.push(2);
|
||||
EXPECT_EQ(fmt::format("{}", s), "[1, 2]");
|
||||
EXPECT_EQ(fmt::format("{}", const_cast<const decltype(s)&>(s)), "[1, 2]");
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user