[linux-audio-dev] [ot] [rant] gcc, you let me down one time too many

Simon Jenkins sjenkins at blueyonder.co.uk
Mon Jun 6 18:48:31 UTC 2005


On Mon, 2005-06-06 at 10:43 +0200, Tim Goetze wrote:
> <snip/>
> What I have is this (from caps code):
> 
> class DescriptorStub
> : public LADSPA_Descriptor
> {
>    /* just a constructor and destructor here */
> };
> 
> template <class T>
> class Descriptor
> : public DescriptorStub
> {
>    public:
>      Descriptor()
>        { setup(); }
> 
>      void setup();
> 
>      ...
> };
> 
> The following is OK for an older g++:
> 
> void
> Descriptor<AmpIV>::setup()
> {
>    UniqueID = 1794;
>    ...
> }
> 
> but g++ since 4.0 wants this instead:
> 
> template <> void
> Descriptor<AmpIV>::setup()
> {
>    ...
> }
> 
> I cannot for the life of me imagine a good reason why "template <>" 
> should be necessary. "setup()" was never declared as a template, let 
> alone one with an empty template parameter.
> 
> If this is indeed prescribed by the language standard, I'll have a 
> very, very hard time getting over it.


> It may not look like much but you have to understand that to me coding 
> is also an exercise in aesthetics.
> 

Then perhaps you shouldn't be cracking this little nut with the
sledgehammer of template specialisation, regardless of whether g++ used
to supply a non-standard one with a shorter handle? ;)

How about adding the unique IDs as static member constants to AmpIV and
its brethren like this:

class AmpIV {
    ...
public:
    static const unsigned UniqueID = 1794;
    ...
};

...which your Descriptor template can pick up without using any
specialisation like this:

template <class T>
class Descriptor
: public DescriptorStub
{
public:
    Descriptor() { UniqueID = T::UniqueID; }
     ...
};

Just a thought.

Cheers

Simon





More information about the Linux-audio-dev mailing list