Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Template disambiguation

Reply
Thread Tools

Template disambiguation

 
 
John Collins
Guest
Posts: n/a
 
      12-28-2004
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
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      12-29-2004
"John Collins" <> wrote...
>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.



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

V


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
out of class declaration virtual function disambiguation bonzo C++ 1 10-15-2008 10:33 AM
User error or g++ disambiguation bug? Nomen Nescio C Programming 10 08-24-2007 03:49 AM
User error or g++ disambiguation bug? spamfree@mailinator.com C++ 1 08-21-2007 08:41 PM
technique to enter text using a mobile phone keypad (T9dictionary-based disambiguation) =?windows-1250?Q?Petr_Jake=9A?= Python 11 08-10-2006 11:32 AM
template and disambiguation Xenos C++ 2 04-29-2004 10:03 AM



Advertisments