[omniORB] compiling template with I::_ptr_type *
Duncan Grisby
dgrisby@uk.research.att.com
Thu, 01 Feb 2001 10:13:37 +0000
On Wednesday 31 January, Janet Tvedt wrote:
> 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)
> { ... }
Ah, so you really do want a pointer to an object reference, not just
an object reference.
> The call to the function looked like the following (for an interface
> OCS::IAttributeDB)
>
> OCS::IAttributeDB *obj;
> getObjectReference( &obj, ... );
[...]
> 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, ...
I was forgetting about the need for typename. I think you can get away
without using it on some compilers. What you want is
template <class Type>
int
getObjectReference(typename Type::_ptr_type *a, ...
typename tells the compiler that the thing you are referencing in the
Type class is a type, rather than anything else. In this case it's
redundant, since Type::_ptr_type must be a type when used like that,
but the C++ standard says you have to do it.
Cheers,
Duncan.
--
-- Duncan Grisby \ Research Engineer --
-- AT&T Laboratories Cambridge --
-- http://www.uk.research.att.com/~dpg1 --