Hello group,
Consider such a class hierachy:
template<typename Type>
class SomeConcreteUsefulClass {}
template<typename Type, typename SomeUsefulClass>
class BaseClass {}
template<typename Type>
class BaseClass<Type, SomeConcreteUsefulClass<Type> > {} // line 10
The compiler (g++) complains about syntax error before '>' on line 10.
Is it illegal to use the declared typename in the type specification of
a template class in template args list, or am I just missing something
in my code?
Thanks in advance,
melfar 7 1682 me****@gmail.com wrote: Hello group,
Consider such a class hierachy:
template<typename Type> class SomeConcreteUsefulClass {}
template<typename Type, typename SomeUsefulClass> class BaseClass {}
template<typename Type> class BaseClass<Type, SomeConcreteUsefulClass<Type> > {} // line 10
The compiler (g++) complains about syntax error before '>' on line 10. Is it illegal to use the declared typename in the type specification of a template class in template args list, or am I just missing something in my code?
Apart from semi-columns after class definitions (you *did* put
semi-columns, did you?), everything compiles fine here. Do you have a
more complete example?
Jonathan
Yeah, semi-colons are in place.
In the actual code there's just one more template parameter in the
list.
Interestingly, if I substitute SomeConcreteUsefulClass<Type> with Test
(and adding a forward-declaration of class Test; ), it successfully
goes through.
the definition of SomeConcreteUsefulClass is properly #included.
Jonathan Mcdougall <jo***************@gmail.com> wrote: Apart from semi-columns after class definitions (you *did* put semi-columns, did you?), everything compiles fine here. Do you have a more complete example?
<nit>
They are semicolons, not semi-columns.
</nit>
--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Marcus Kwok wrote: Jonathan Mcdougall <jo***************@gmail.com> wrote: Apart from semi-columns after class definitions (you *did* put semi-columns, did you?), everything compiles fine here. Do you have a more complete example?
<nit> They are semicolons, not semi-columns. </nit>
Oh, thanks, good to know :)
Jonathan "French Canadian" Mcdougall me****@gmail.com wrote: Yeah, semi-colons are in place. In the actual code there's just one more template parameter in the list. Interestingly, if I substitute SomeConcreteUsefulClass<Type> with Test (and adding a forward-declaration of class Test; ), it successfully goes through. the definition of SomeConcreteUsefulClass is properly #included.
Well just post a complete, "compilable" example that fails on your
compiler.
Jonathan
There was a problem by my side.
SomeConcreteUsefulClass contains a cross reference to BaseClass.
So, in fact it was undefined on the moment of declaration of BaseClass.
If I add a forward declaration of SomeConcreteUsefulClass :
template<typename T> class SomeConcreteUsefulClass;
The code compiles okay, but after the inclusion of actual
SomeConcreteUsefulClass definition, the actual code doesn't seem to be
compiled.
I get symbol not found exceptions from the dynamic linker on runtime.
Is it okay to forward declare template classes? me****@gmail.com wrote:
Please quote the message you are answering to. There was a problem by my side. SomeConcreteUsefulClass contains a cross reference to BaseClass. So, in fact it was undefined on the moment of declaration of BaseClass.
If I add a forward declaration of SomeConcreteUsefulClass :
template<typename T> class SomeConcreteUsefulClass;
The code compiles okay, but after the inclusion of actual SomeConcreteUsefulClass definition, the actual code doesn't seem to be compiled. I get symbol not found exceptions from the dynamic linker on runtime.
You don't seem to want to post your code. How can we help you?
Is it okay to forward declare template classes?
Yes.
Jonathan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul MG |
last post by:
Hi
Template partial specialization always seems like a fairly
straightforward concept - until I try to do it :).
I am trying to implement the input sequence type (from Stroustrup
section...
|
by: Patrick Kowalzick |
last post by:
Dear all,
I have a question about default template parameters.
I want to have a second template parameter which as a default parameter,
but depends on the first one (see below). Is something...
|
by: Agent Mulder |
last post by:
Hi group,
I have a problem with partial template specialization. In the code
below I have a template struct Music with one method, play(),
and three kinds of music, Jazz, Funk and Bach. When I...
|
by: BekTek |
last post by:
I'm still confused about the template partial specialization which is used
in many libraries..
due to lack of introduction for beginner..
Could you tell me about that in short?
Thanks in...
|
by: Levent |
last post by:
Hi,
Why doesn't this work? (tried with gcc 3.3.3 and VC++ 7.1):
#include <iostream>
template<class T, unsigned N>
struct Foo {
void func();
};
template<class T, unsigned N>
|
by: Alfonso Morra |
last post by:
if I have a class template declared as ff:
(BTW is this a partial specialization? - I think it is)
template <typename T1, myenum_1 e1=OK, my_enum_2=NONE>
class A {
public:
A();
virtual...
|
by: Marek Vondrak |
last post by:
Hello.
I have written the following program and am curious why it prints "1" "2".
What are the exact effects of explicitly providing function template
parameters at the call? Is the second...
|
by: stephen.diverdi |
last post by:
Can anyone lend a hand on getting this particular template
specialization working? I've been trying to compile with g++ 4.1 and
VS 2005.
...
|
by: flopbucket |
last post by:
Hi,
I want to provide a specialization of a class for any type T that is a
std::map.
template<typename T>
class Foo
{
// ...
};
|
by: Ioannis Gyftos |
last post by:
Hello,
First the code :)
///////////////////////////////////////////////////////////////////////////////////
// in another header file
namespace LJC{
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |