The following is a much simplified version of some code that is
refusing to compile. Is there anything technically wrong with the
code?
class ClassWithTemplateFunction
{
public:
template<class Tinline void SomeSillyFunction(T value) const
{
}
};
template <typename Tvoid TemplateFunction( ClassWithTemplateFunction
& rC, T value)
{
rC.SomeSillyFunction< T >( value );
}
int main()
{
ClassWithTemplateFunction C;
int value = 0;
TemplateFunction<int>(C, value);
return 0;
}
The error I get from the compiler is " Parse error before '>' " on the
line: rC.SomeSillyFunction< T >( value );
Any help would be appreciated. 9 1206
easy wrote:
The following is a much simplified version of some code that is
refusing to compile. Is there anything technically wrong with the
code?
class ClassWithTemplateFunction
{
public:
template<class Tinline void SomeSillyFunction(T value) const
{
}
};
template <typename Tvoid TemplateFunction( ClassWithTemplateFunction
& rC, T value)
{
rC.SomeSillyFunction< T >( value );
}
int main()
{
ClassWithTemplateFunction C;
int value = 0;
TemplateFunction<int>(C, value);
return 0;
}
The error I get from the compiler is " Parse error before '>' " on the
line: rC.SomeSillyFunction< T >( value );
Any help would be appreciated.
Try:
rC.template SomeSillyFunction< T >( value );
On 16 Feb, 16:19, "easy" <chris.mich...@lmco.comwrote:
The following is a much simplified version of some code that is
refusing to compile. Is there anything technically wrong with the
code?
class ClassWithTemplateFunction
{
public:
template<class Tinline void SomeSillyFunction(T value) const
{
}
};
template <typename Tvoid TemplateFunction( ClassWithTemplateFunction
& rC, T value)
{
rC.SomeSillyFunction< T >( value );
}
int main()
{
ClassWithTemplateFunction C;
int value = 0;
TemplateFunction<int>(C, value);
return 0;
}
The error I get from the compiler is " Parse error before '>' " on the
line: rC.SomeSillyFunction< T >( value );
Any help would be appreciated.
What compiler are you using?
Using MS Visual Studio 2005 your code compiles with no errors and when
I step through in the debugger it follows the expected path. Also, the
code compiles without errors in Comeau online (can't execute it there
to see what happens).
Gavin Deane
On Feb 16, 10:28 am, "Gavin Deane" <deane_ga...@hotmail.comwrote:
On 16 Feb, 16:19, "easy" <chris.mich...@lmco.comwrote:
The following is a much simplified version of some code that is
refusing to compile. Is there anything technically wrong with the
code?
class ClassWithTemplateFunction
{
public:
template<class Tinline void SomeSillyFunction(T value) const
{
}
};
template <typename Tvoid TemplateFunction( ClassWithTemplateFunction
& rC, T value)
{
rC.SomeSillyFunction< T >( value );
}
int main()
{
ClassWithTemplateFunction C;
int value = 0;
TemplateFunction<int>(C, value);
return 0;
}
The error I get from the compiler is " Parse error before '>' " on the
line: rC.SomeSillyFunction< T >( value );
Any help would be appreciated.
What compiler are you using?
Using MS Visual Studio 2005 your code compiles with no errors and when
I step through in the debugger it follows the expected path. Also, the
code compiles without errors in Comeau online (can't execute it there
to see what happens).
Gavin Deane- Hide quoted text -
- Show quoted text -
compiler = gcc 3.3.5
On Feb 16, 10:23 am, Rolf Magnus <ramag...@t-online.dewrote:
easy wrote:
The following is a much simplified version of some code that is
refusing to compile. Is there anything technically wrong with the
code?
class ClassWithTemplateFunction
{
public:
template<class Tinline void SomeSillyFunction(T value) const
{
}
};
template <typename Tvoid TemplateFunction( ClassWithTemplateFunction
& rC, T value)
{
rC.SomeSillyFunction< T >( value );
}
int main()
{
ClassWithTemplateFunction C;
int value = 0;
TemplateFunction<int>(C, value);
return 0;
}
The error I get from the compiler is " Parse error before '>' " on the
line: rC.SomeSillyFunction< T >( value );
Any help would be appreciated.
Try:
rC.template SomeSillyFunction< T >( value );- Hide quoted text -
- Show quoted text -
I am unfamilliar with inserting the operator "template" in the
function call. I will try it.
On Feb 16, 10:23 am, Rolf Magnus <ramag...@t-online.dewrote:
easy wrote:
The following is a much simplified version of some code that is
refusing to compile. Is there anything technically wrong with the
code?
class ClassWithTemplateFunction
{
public:
template<class Tinline void SomeSillyFunction(T value) const
{
}
};
template <typename Tvoid TemplateFunction( ClassWithTemplateFunction
& rC, T value)
{
rC.SomeSillyFunction< T >( value );
}
int main()
{
ClassWithTemplateFunction C;
int value = 0;
TemplateFunction<int>(C, value);
return 0;
}
The error I get from the compiler is " Parse error before '>' " on the
line: rC.SomeSillyFunction< T >( value );
Any help would be appreciated.
Try:
rC.template SomeSillyFunction< T >( value );- Hide quoted text -
- Show quoted text -
rC.template SomeSillyFunction< T >( value ); compiles. I will have to
study more the keyword "template".
Rolf Magnus wrote:
easy wrote:
>The following is a much simplified version of some code that is refusing to compile. Is there anything technically wrong with the code?
class ClassWithTemplateFunction { public: template<class Tinline void SomeSillyFunction(T value) const { } };
template <typename Tvoid TemplateFunction( ClassWithTemplateFunction & rC, T value) { rC.SomeSillyFunction< T >( value ); }
int main() { ClassWithTemplateFunction C;
int value = 0;
TemplateFunction<int>(C, value);
return 0; }
The error I get from the compiler is " Parse error before '>' " on the line: rC.SomeSillyFunction< T >( value );
Any help would be appreciated.
Try:
rC.template SomeSillyFunction< T >( value );
My fix is: rC.SomeSillyFunction( value );
This way the compiler is left to figure out how to instantiate the
template. Your fix is rather confusing? Why is adding 'template' here a
resolution? Can you make an analogy as an explanation?
* Fei Liu:
Rolf Magnus wrote:
>> Try:
rC.template SomeSillyFunction< T >( value );
My fix is: rC.SomeSillyFunction( value );
This way the compiler is left to figure out how to instantiate the
template. Your fix is rather confusing? Why is adding 'template' here a
resolution? Can you make an analogy as an explanation?
Using the 'template' keyword is a more general fix, because it lets you
choose the template parameter(s) independent of the argument's type(s).
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Fei Liu wrote:
Rolf Magnus wrote:
>easy wrote:
>Try:
rC.template SomeSillyFunction< T >( value );
My fix is: rC.SomeSillyFunction( value );
This way the compiler is left to figure out how to instantiate the
template. Your fix is rather confusing? Why is adding 'template' here a
resolution? Can you make an analogy as an explanation?
I thought template in this context was a FAQ, kind of like typedef
typename xxx. Apparently not.
On Feb 16, 12:21 pm, Fei Liu <fei...@aepnetworks.comwrote:
Rolf Magnus wrote:
easy wrote:
The following is a much simplified version of some code that is
refusing to compile. Is there anything technically wrong with the
code?
class ClassWithTemplateFunction
{
public:
template<class Tinline void SomeSillyFunction(T value) const
{
}
};
template <typename Tvoid TemplateFunction( ClassWithTemplateFunction
& rC, T value)
{
rC.SomeSillyFunction< T >( value );
}
int main()
{
ClassWithTemplateFunction C;
int value = 0;
TemplateFunction<int>(C, value);
return 0;
}
The error I get from the compiler is " Parse error before '>' " on the
line: rC.SomeSillyFunction< T >( value );
Any help would be appreciated.
Try:
rC.template SomeSillyFunction< T >( value );
My fix is: rC.SomeSillyFunction( value );
This way the compiler is left to figure out how to instantiate the
template. Your fix is rather confusing? Why is adding 'template' here a
resolution? Can you make an analogy as an explanation?- Hide quoted text -
- Show quoted text -
Once I knew what to look for I found this discussion. Very helpful. http://groups.google.com/group/comp....ff203f27c5bfb0 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: C. Carbonera |
last post by:
/*
Hi,
I have a problem with explicit instantiation of templates in Visual
C++ 6.0.
I have provided the source below. I have an example of a function
template that produces incorrect output in...
|
by: Adam Parkin |
last post by:
Hello, all I'm having a problem with friend functions in a templatized Queue
class I'm writing using linked lists. The problem is that I can't get the
friend function to be able to access private...
|
by: Drew McCormack |
last post by:
I have a C++ template class which contains a static variable whose
construction registers the class with a map. Something like this:
template <typename T>
class M {
static Registrar<M>...
|
by: Lionel B |
last post by:
Greetings.
The following code compiles ok and does what I'd expect it to do:
---------- START CODE ----------
// test.cpp
|
by: David Komanek |
last post by:
Hi all,
I am trying to learn more about how to use g++/Cygwin to produce dll
files on WinXP. And I have a problem which at the first look seems to
be an obvious dll-export problem, but I don't...
| |
by: Amit |
last post by:
Greetings all,
I am writing some code somehwat similar to the test code I have below. I am
having a variety of issues with template specialization. I am not sure if
this is related to something...
|
by: Siegfried Weiss |
last post by:
Hi guys,
i give up finding a solution by reading or by trial & error. Hope, YOU
can help me! (Sorry for my rather long posting.)
Stroustrup says, that templates could be declared with
- type...
|
by: Chris |
last post by:
I am having a very strange problem involving virtual
functions in template classes. First of all, here is an
extremely simplified structure of the two classes I am
having problems with.
...
|
by: aaragon |
last post by:
Hi everyone. A very simple question. I would like to know what is
better in terms of performance. I want to use a simple function to
obtain the minimum of two values. One way could be using a...
|
by: Hamilton Woods |
last post by:
Diehards,
I developed a template matrix class back around 1992 using Borland C++ 4.5
(ancestor of C++ Builder) and haven't touched it until a few days ago. I
pulled it from the freezer and...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |