#include #include #include #define FILELINE( l ) __FILE__ #l struct fileline { virtual std::string msg() { return std::string(); } }; template struct filelineT { virtual std::string msg() { std::ostringstream ss; ss << file << ':' << line; return ss.str(); } }; std::string flfunc( const char * f = __FILE__, int l = __LINE__ ) { std::ostringstream ss; ss << f << ':' << l; return ss.str(); } #define FLFUNC flfunc( __FILE__, __LINE__ ) //#define filelineM {static const char * tmp = __FILE__; filelineT} //template < struct A { std::string myName; A( std::string n = FLFUNC ) : myName( n ) {} }; int main () { A a1( FLFUNC ); A a2( FLFUNC ); std::cout << a1.myName << std::endl; std::cout << a2.myName << std::endl; return 0; }