获取模板参数中的返回函数类型 [英] Get return type of function in template parameter

查看:83
本文介绍了获取模板参数中的返回函数类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是否真的是获取模板参数中定义的函数的派生类返回类型的首选方法?

Is this really the preferred way to get the return type, for use in a derived class, of a function defined in the template parameter?

展开 | 选择 | Wrap | 行号

推荐答案

试试这个:
Try this:
展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号


当我想要的是typedef时,为什么要将数据成员引入基类?
Why would I introduce a data member into a base class when all I want is a typedef?


它避免了类型转换以及PARAMETER需要函数()返回R的依赖性。

我目前的观点是,除非你使用遗留的C代码,否则C ++中的类型转换意味着你处于消防状态,需要做一些丑陋的事情,或者你的设计搞砸了。


我只有Visual Studio 2008并且无法让编译器接受你的码。它在reinterpret_cast上噱头。
It avoids the typecast and the dependence that PARAMETER is required to have a function() returning R.

My current opinion is that unless you are working with legacy C code a typecast in C++ means either that you are in a firefighting situation and need to do some ugly things or that your design is screwed up.

I only have Visual Studio 2008 and was not able to get the compiler to accept your code. It gags on the reinterpret_cast.


这篇关于获取模板参数中的返回函数类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆