[omniORB] compiling template with I::_ptr_type *

Janet Tvedt tvedt@noao.edu
Wed, 31 Jan 2001 16:33:19 -0700 (MST)


My original code which worked under Visibroker C++ for Tornado
and omniORB2 used the template function:

template <class Type> 
int
getObjectReference(Type **a, const char *name, CosNaming::NamingContext_var nc, int maxRetries)
{ ... }

The call to the function looked like the following (for an interface OCS::IAttributeDB)

OCS::IAttributeDB *obj;
getObjectReference( &obj, ... );


I get the compilation error "parse error before `,'" with either of the following
changes:
 
    getObjectReference(Type::_ptr_type a, ...
 
    getObjectReference(Type::_ptr_type *a, ...

If I add typename (similar to a function Ch. 18 of Advanced CORBA Programming with C++,
Henning & Vinoski) the following template compiles:

template <class Type> 
int
getObjectReference(typename Type::_ptr_type a, ...

but I get the compilation error

no matching function for call to `getObjectReference (OCS::_objref_IAttributeDB *&, const char *, CosNaming::NamingContext_var, int)

when I try to call the function like so:

OCS::IAttributeDB_ptr obj;
getObjectReference( obj, ... );


I am not experienced with using templates so maybe I was just lucky
that what I had done previously worked.

Any advice would be greatly appreciated.


--------------------------------------------------------------------------
Janet Tvedt, National Solar Observatory/SOLIS   Internet: tvedt@noao.edu
P.O. Box 26732, Tucson, AZ  85732-6732          Phone:    (520) 318-8388
950 N. Cherry Ave., Tucson, AZ  85719           FAX:      (520) 318-8278

> On Monday 29 January, Janet Tvedt wrote:
> 
> > A few months ago I posted a message (details below).  However,
> > I cannot get the following template function to compile:
> >  
> >      template <class Type> 
> >      int getCosNamingObjectRef(Type::_ptr_type *a, ...
> 
> Depending on what you are trying to do, you quite probably want to be
> using
> 
>      template <class Type> 
>      int getCosNamingObjectRef(Type::_ptr_type a, ...
> 
> without the *. Other than that, precisely what error message are you
> getting?
> 
> Cheers,
> 
> Duncan.
> 
> -- 
>  -- Duncan Grisby  \  Research Engineer  --
>   -- AT&T Laboratories Cambridge          --
>    -- http://www.uk.research.att.com/~dpg1 --
> 
>