Loki again (from Singleton.h)

Paolo Carlini pcarlini@unitus.it
Sat Apr 21 10:29:00 GMT 2001


Hi all,

I promised to ask your advice for the non-obvious (for me ;) compilation
problems of the Loki library (www.moderncppdesign.com).

This one is from the Singleton.h header.

It was quite difficult to distillate, but in this case I'm almost sure
that Gcc is right :) and the *code* must be corrected:

-----------
template <typename T, typename Destroyer>
void SetLongevity(T* pDynObject, unsigned int longevity, Destroyer d)
{
}

class SingletonWithLongevity
{
public:
    void ScheduleDestruction(int* pObj)
    {
        struct Adapter
        {
        };

  Adapter adapter;
 SetLongevity(pObj, (unsigned int) 1, adapter);
    }
} Singleton;

int main()
{
    static int num;

    Singleton.ScheduleDestruction(&num);
}
----------

Do you all agree that "'void
SingletonWithLongevity::ScheduleDestruction(int*)::Adapter' composed
from a local class is not a valid template-argument" ???

Thanks,
Paolo.




More information about the Gcc mailing list