根据原博客:http://blog.csdn.net/hengyunabc/article/details/7773250 实验
#include <iostream>
using namespace std;template<int I> struct arg {
arg() {
}
};
template<class A1> struct storage1 {
explicit storage1(A1 a1) :
a1_(a1) {
cout<<"storage1 storage1(A1 a1)"<<endl;
}
A1 a1_;
};
template<class A1, int I> struct storage2: public storage1<A1> {
typedef storage1<A1> inherited;
storage2(A1 a1) :
storage1<A1>(a1) {
cout<<"storage2 storage2(A1 a1, A2 a2)"<<endl;
}
static arg<I> a2_() {
return arg<I>();
}
};
namespace {
arg<1> _1;
arg<2> _2;
}
void test(arg<1> ) {
cout << "list2 A1 operator[](boost::arg<1>)" << endl;
return;
}
void test (arg<1> (*)()) {
cout << "list2 A1 operator[](boost::arg<1> (*)())" << endl;
return;
}
int main() {
int i1 = 111, i2 = 222;
arg<8> _8;
storage2 < int,1> b(1);
test(storage2 < int,1>::a2_); //(storage2 < int,1>::a2_ 这个是函数指针 所以会调用void test (arg<1> (*)())
test(storage2 < int,1>::a2_()); //(storage2 < int,1>::a2_() 调用类静态方法 返回 arg<1> 类型 所以会调用void test(arg<1> )
}