Давайте посмотрим, как это будет работать, если это будет не функция-член, если мы сделаем this
явным параметром (мнимый синтаксис):
void call(S* this, int*) {
// Wha? we clearly know `S*` is not const
std::is_const_v<typename std::remove_reference_t<decltype(*this)> >
}
void call(S const* this, int const*) {
// same
std::is_const_v<typename std::remove_reference_t<decltype(*this)> >
}
Решением будет удаление функций с различным постоянством между параметрами:
void call(S* this, int*) {}
void call(S const* this, int const*) {}
void call(S* this, int const*) = delete;
void call(S const* this, int*) = delete;
Теперь то же самое можно сделать с помощью функции-члена:
struct S {
void operator()(int*) {}
void operator()(int const*) const {}
void operator()(int const*) = delete;
void operator()(int*) const = delete;
};