60 lines
843 B
C++
60 lines
843 B
C++
|
|
#include <iostream>
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
#define FILELINE( l ) __FILE__ #l
|
|
|
|
struct fileline
|
|
{
|
|
virtual std::string msg()
|
|
{
|
|
return std::string();
|
|
}
|
|
};
|
|
|
|
template <const char * file, int line>
|
|
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<tmp,__LINE__>}
|
|
|
|
//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;
|
|
}
|
|
|