我可以默认一个函数参数为__FILE__的值在调用者吗? [英] Can I default a function argument to the value of __FILE__ at the caller?
本文介绍了我可以默认一个函数参数为__FILE__的值在调用者吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C ++中,我可以有一个默认为 __ PRETTY_FUNCTION ___
, ___ FILE ___
code> ___ LINE __ 在调用者的点处定义,而不是在头文件中提供的默认值而不使用宏?
In C++, can I have a defaulted argument to a function which defaults to __PRETTY_FUNCTION___
, ___FILE___
, and ___LINE__
as defined at the point of the caller and not the point the defaults are supplied in a header file without using macros?
推荐答案
你不能,但你可以用一个额外的宏来加强这种行为。例如:
You can't, but you can acheive this behavior with an additional macro. For instance:
#DEFINE THROW(e) throwException(e, __FILE__, __LINE__);
注意, __ PRETTY_FUNCTION __
标准。
这篇关于我可以默认一个函数参数为__FILE__的值在调用者吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文