SpringBoot整合SpringSecurit(二)通过token进行访问

诗远

关注

阅读 5

2024-06-09

#include <iostream>


template<typename Tag, typename Tag::type M>
struct Rob {
    friend typename Tag::type get(Tag){
        return M;
    }
};

// use
struct A {
    A(int a):a(a){}
private:
    int a;
};

// tag used to access A::a
struct A_f{
    typedef int A::*type;
    friend type get(A_f);
};

template struct Rob<A_f, &A::a>;

int main(){
    A a(42);
    std::cout << "proof:" << a.*get(A_f()) << std::endl;
}

精彩评论(0)

0 0 举报