Connecting Tech Pros Worldwide Forums | Help | Site Map

Template disambiguation

John Collins
Guest
 
Posts: n/a
#1: Jul 23 '05
I just tried to build under GNU C++ 3.4.1 and then 3.4.3 a program which was
working fine under G++ 3.3.*

It uses template members "shm_cast" to obtain a pointer "foo *" to a
structure in shared memory from an offset "off" thus

template<typename T> T *shm_cast(const shmoff_t off) const
{
return static_cast<T*>(shmp(off));
}

used thus:

foo *item = seg.template shm_cast<foo>(off);

This is according to Stroustrup Appendix C13.6

If "template" is left out there it doesn't parse it right as was the case in
G++ 3.3.*.

It works fine with 3.3.* but with G++ 3.4.* it reports

error: `template' (as a disambiguator) is only allowed within templates

Please can anyone advise if G++ 3.4.* is broken or has some different syntax
been coined for this I haven't heard about.

Thanks if anyone can help.

--
John Collins Xi Software Ltd www.xisl.com

Victor Bazarov
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Template disambiguation


"John Collins" <jmc@nospam.xisl.com> wrote...[color=blue]
>I just tried to build under GNU C++ 3.4.1 and then 3.4.3 a program which
>was
> working fine under G++ 3.3.*
>
> It uses template members "shm_cast" to obtain a pointer "foo *" to a
> structure in shared memory from an offset "off" thus
>
> template<typename T> T *shm_cast(const shmoff_t off) const
> {
> return static_cast<T*>(shmp(off));
> }
>
> used thus:
>
> foo *item = seg.template shm_cast<foo>(off);
>
> This is according to Stroustrup Appendix C13.6
>
> If "template" is left out there it doesn't parse it right as was the case
> in
> G++ 3.3.*.
>
> It works fine with 3.3.* but with G++ 3.4.* it reports
>
> error: `template' (as a disambiguator) is only allowed within templates
>
> Please can anyone advise if G++ 3.4.* is broken or has some different
> syntax
> been coined for this I haven't heard about.[/color]


Please post _complete_ code that can be run through a compiler.

V


Closed Thread