??C++????????????????????????????
???????????? ???????[ 2013/4/24 10:02:45 ] ????????
????????????????????????
????????4??
template<typename T>
struct IsString
{
enum { value = false };
};
template<>
struct IsString<string>
{
enum { value = true };
};
template<typename T1?? typename T2>
struct Base
{
//other function
//....
void Func()
{
if(IsString<T2>::value)
{
cout << "specialization function" << endl;
}
else
{
cout << "primary function" << endl;
}
}
};
???????????????????????ж?????
????????5??
template<typename T3?? typename T4>
struct must_be_same_type
{
enum { ret = 0 };
};
template<>
struct must_be_same_type<string?? string>
{
enum { ret = 1 };
};
template < typename T1??typename T2 >
class Base{
public:
//other function
//....
void Func(){
if(must_be_same_type<T2?? string>::ret)
{
cout << "specialization function" << endl;
}
else
{
cout << "primary function" << endl;
}
}
};
???????????????4??????????????????????
????????????????????????????????д?????????(delegate)????????£?
template<typename return_type?? typename first_type?? typename second_type>
class CEvent
{
public:
//other function
//....
return_type operator()(first_type p1?? second_type p2)
{
return_type ret = return_type();
//...
//ret = invoker(p1?? p2);
return ret;
}
};
void test3()
{
CEvent<int?? int?? int> e1;
e1(1?? 2);
CEvent<void?? int?? int> e2;
e2(1?? 2);
}
int main()
{
test3();
}
??????

???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11