获取模板参数中的返回函数类型

编程入门 行业动态 更新时间:2024-10-25 00:29:29
本文介绍了获取模板参数中的返回函数类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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: 展开 | 选择 | 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.

更多推荐

获取模板参数中的返回函数类型

本文发布于:2023-07-22 10:35:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1186745.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   模板   参数   类型

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!