#include <type_traits>

template<class Fty>
struct is_ptcmf : std::false_type{};

template<class C, class R, class... Args>
struct is_ptcmf<R (C::*)(Args...) const> : std::true_type{};

template<class C, class Fty, Fty F>
struct A{
  static_assert(std::is_const<C>() == is_ptcmf<Fty>(), "Must pair const with const.");
};

struct X{
    void foo(){}
    void bar() const{}
};

template<class... Args>
void swallow(Args&&...){}

int main(){
    A<X, decltype(&X::foo), &X::foo> a1;
    A<X const, decltype(&X::bar), &X::bar> a2;
    swallow(a1, a2);
    
    //A<X const, decltype(&X::foo), &X::foo> a3; // error: static_assert
    //A<X, decltype(&X::bar), &X::bar> a4; // error: static_assert
    //swallow(a3, a4)
}