PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

template question

angedelamort · 24 Sep 2004, 19:23 UTC
Hello,
Here my problem:

Code:

template<class T>
void Fct(int i)
{
std::cout << i << std::endl;
}

// ...

Fct<int>(__LINE__); // <-- This line

// ...


I was wondering if it was possible to have the macro __LINE__ as a default value? Because of the template, I cannot use a simple macro for that. So I was wondering if there was a work around? I've tryed many things, but in vain :(
Sure thing, using an extra macro:


Code:

#define CALL_FCT() Fct<int>(__LINE__)


Then at call site:

Code:

CALL_FCT();
angedelamort · 24 Sep 2004, 19:53 UTC
yes I can do that, But I was wondering if it was possible with template (default values). Seems not. But your solution is so simple that I didn't think about it lol. Thanks for the hint.
Another macro is the only way to get __LINE__ to work the way you want it to.