[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

More problems with SPTR



Abstract: fallback position for initialized default SPTR arguments

   Date: Mon, 6 Nov 89 17:38:16 PST
   From: eric@son-of-blob

     extern TEMPLATE OF(class M) Accumulation OF2(Set OF(M), Set OF(M)) *
   unionRecruiter (SPTR(Set) OF(M) seed = NULL);

   generates the error
   not implemented: constructor needed for argument initializer
   The manual only says
   "The default argument is a constructor or is an expression that invokes a
   constructor."
   The way that I (unfortunately) read this is that we can't have default
   arguments where the argument must be a strong pointer in C++2.0.

   Any suggestions?

I just realized what the fallback position is if we can't figure this
one out.  It's to use overloading to simulate initialized default
arguments:


  inline TEMPLATE OF(class M) Accumulation OF2(Set OF(M), Set OF(M)) *
unionRecruiter ()
{
    return unionRecruiter (NULL);
}

  extern TEMPLATE OF(class M) Accumulation OF2(Set OF(M), Set OF(M)) *
unionRecruiter (SPTR(Set) OF(M) seed);


In a peculiar way, this is not surprising, as default arguments can
just be seen as syntactic sugar for the above overloading pattern.
However, this piece of sugar really has been quite sweet.  Losing
this will make the code much uglier, so please, someone out there,
please think of something.

At least it isn't a show stopper :-|