返回   cpper编程论坛 > C/CPP/TMP/GP
注册账号 论坛帮助 会员列表 日历事件 搜索 今日新帖 标记版面已读

回复
 
LinkBack 主题工具 显示模式
  #1 (permalink)  
旧 2007-11-20
bankrock 的头像
高级会员
 
注册日期: 2003-12-11
帖子: 843
文章: 7
bankrock 正向着好的方向发展
默认 成员函数指针的模版推导

想把成员函数指针的函数类型分离出来,结果手头的编译器(gcc, VC全都编译不过去:
代码:
#include<iostream> #include <cmath> using namespace std; class Vol { public: void Print() {}; }; void Print() { cout << "Print" << endl; } //T -- Member Type //C -- Class Type template <class T, class C> void CatchMemFunc(T C::*) { T* p = &Print; (*p)(); } typedef void (FuncT)(); void NonTempCatch(FuncT Vol::* ) { FuncT* p= &Print; (*p)(); } int main() { //CatchMemFunc(&Vol::Print); ----编译错误 NonTempCatch(&Vol::Print); system("pause"); return 0; }
NonTempCatch是详细指明了函数类型才编译过去的,可是依赖模版推导的CatchMemFunc完全不行,推荐个能编译过去的编译器吧
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #2 (permalink)  
旧 2007-11-23
高级会员
 
注册日期: 2002-09-19
帖子: 839
文章: 7
tomato 正向着好的方向发展
默认 回复: 成员函数指针的模版推导

comeau c++
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #3 (permalink)  
旧 2007-11-24
bankrock 的头像
高级会员
 
注册日期: 2003-12-11
帖子: 843
文章: 7
bankrock 正向着好的方向发展
默认 回复: 成员函数指针的模版推导

试了网上编译的功能,过了。这个编译器好像很符合标准,可惜要收刀的,电驴上也找不到,那里有下载么?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
回复

书签

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码
Trackbacks are 启用
Pingbacks are 启用
Refbacks are 启用



所有时间均为格林尼治时间 +9。现在的时间是 08:42 AM


Powered by vBulletin® 版本 3.7.0
版权所有 ©2000 - 2008,Jelsoft Enterprises Ltd.
(C) Copy Right All Right Reserved 2001 - 2007

Search Engine Friendly URLs by vBSEO 3.1.0