__PRETTY_FUNCTION__:返回类型可以包含括号吗?
__PRETTY_FUNCTION__: Can a return type contain parentheses?
我正在考虑这个解决方案来减少__PRETTY_FUNCTION__
的输出。该解决方案删除了返回类型、参数和修饰符。
我想知道以下修改是否在任何情况下都有效:
inline std::string methodName(const std::string& prettyFunction) {
size_t parenthesis = prettyFunction.find("("); //Then I can use parenthesis index as end for my string
size_t begin = prettyFunction.rfind(" ",parenthesis) + 1;
(...)
}
也就是说,我想了解返回类型(或其他任何内容,在函数名称左侧由 __PRETTY_FUNCTION__
返回的字符串中)是否可能包含一个左括号(
我以不同的方式实现了该方法。
是的,可以有其他括号。 下面是一个示例:
#include <iostream>
using fptr = void(*)();
fptr func() {
std::cout << __PRETTY_FUNCTION__ << 'n';
return nullptr;
}
int main()
{
func();
}
使用 g++ -std=c++14 的输出为:
void (* func())()
相关文章:
- 如何导出包含具有"std::unique_ptr"值的"std::map"属性的
- 从包含m行的文件中提取n行,必要时(惰性地)重复该文件
- 编译包含字符串的代码时遇到问题
- c++库的公共头文件中应该包含什么
- 将包含C样式数组的对象初始化为成员变量(C++)
- 是否需要删除包含对象的"pair"?
- 函数何时会在c++中包含stack_Unwind_Resume调用
- 如何将包含epoch时间的十六进制字符串转换为time_t
- 使用mongocxx驱动程序时包含头文件问题
- 如何在h文件中包含.o对象文件
- 在混合代码库中将C转换为C++时出现许多包含错误
- VS2017,C++包含目录与附加包含目录,子文件夹包含失败-但为什么
- cmath抛出错误C2062、C2059、C2143和C2447.cmath包含在矢量文件中
- 为什么您需要C++头文件的包含保护
- 无法在UE4中包含BP类到CPP类
- g++ 说函数不存在,即使包含正确的标头
- 在C++代码中包含opencv时,使用ctypes创建.so文件
- Visual C++GC接口如何启用它以及要包含哪个库
- 当调用switch语句中的函数时(即使函数不包含循环),似乎是永不结束的循环的问题
- 为什么包含windows.h会产生语法错误,从而阻止类的实例化?(C2146,C2065)