[cfe-dev] clang and gcc implement __PRETTY_FUNCTION__ differently

Richard Smith richard at metafoo.co.uk
Sun Dec 18 19:35:08 PST 2011


On Sun, December 18, 2011 21:41, Nikola Smiljanic wrote:
> You're right, the example was stupid. I'm just trying to understand what
> unused template actually means and more importantly how to check if it's used
> or not?

Your example looked reasonable to me (apart from "T t();", which declares a
function...). That's one of the cases in which __PRETTY_FUNCTION__ is
currently ambiguous.

> On Sun, Dec 18, 2011 at 5:44 PM, Joerg Sonnenberger <joerg at britannica.bec.de
> wrote:
>> On Sun, Dec 18, 2011 at 05:01:54PM +0100, Nikola Smiljanic wrote:
>>> But what about
>>>
>>> template<class T> const char *foo() { T t();
>>> std::cout << t;
>>>
>>> return __PRETTY_FUNCTION__; }
>>>
>>
>> That's not valid, is it? E.g. the function doesn't result in
>> non-conflicting specialisations, does it?

It is valid. I don't know what you mean by non-conflicting specializations,
but you can certainly use multiple specializations of that template in the
same program:

const char *p = foo<int>(), *q = foo<char>();

- Richard




More information about the cfe-dev mailing list