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?
Asked
Active
Viewed 1,582 times
8

Brian Tompsett - 汤莱恩
- 5,753
- 72
- 57
- 129

WilliamKF
- 41,123
- 68
- 193
- 295
3 Answers
6
You can't, but you can acheive this behavior with an additional macro. For instance:
#DEFINE THROW(e) throwException(e, __FILE__, __LINE__);
On a side note, __PRETTY_FUNCTION__
is not standard.

KeatsPeeks
- 19,126
- 5
- 52
- 83
0
You probably can... but definitely not with the restriction you mentioned (no macros).

Ben Voigt
- 277,958
- 43
- 419
- 720