马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#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;
}
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |