473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

template template arguments: expected a class template, got `Component<T1, T2, T3>

Any idea why line 57 fails? http://rafb.net/p/86JdGg61.html

gs = MyShutdown<Component, T1, T2, T3>(this);

Errors:

shutdown1.cpp: In constructor `Component<T1, T2, T3>::Component(int)':
shutdown1.cpp:46: error: type/value mismatch at argument 1 in template
parameter list for `template<template<class T1, class T2, class T3>
class Calling_Comp
onent, class T1, class T2, class T3class MyShutdown'
shutdown1.cpp:46: error: expected a class template, got
`Component<T1, T2, T3>'

#include <iostream>
#include <string>

using namespace std;
class Shutdown
{
virtual void begin()
{
cout << "shutdown" << endl;
exit(0);
}
};

Shutdown *gs;

template <template <class T1, class T2, class T3class
Calling_Component, class T1, class T2, class T3>
class MyShutdown : public Shutdown
{
typedef Calling_Component<T1, T2, T3Caller;

Caller& mCaller;

public:
MyShutdown(Caller& rCaller)
: mCaller(rCaller)
{
}

void begin()
{
cout << "MyShutdown caller # " << mCaller.mnId << endl;
exit(0);
}
};

template <typename T1, typename T2, typename T3>
class Component
{
public:

Component(int n)
: mnId(n)
{
gs = MyShutdown<Component, T1, T2, T3>(this);
}

int mnId;
};

int main()
{
Component<int, int, stringc(5);

MyShutdown<Component, int, int, strings(c);

s.begin();
}

Jun 8 '07 #1
1 5145
ga************@gmail.com wrote:
Any idea why line 57 fails? http://rafb.net/p/86JdGg61.html
....
MyShutdown(Caller& rCaller)
do you mean to be passing a reference or a pointer ?
: mCaller(rCaller)
{
}

void begin()
{
cout << "MyShutdown caller # " << mCaller.mnId << endl;
exit(0);
}
};

template <typename T1, typename T2, typename T3>
class Component
{
public:

Component(int n)
: mnId(n)
{
gs = MyShutdown<Component, T1, T2, T3>(this);
Even though Component is an appropriate template, the compiler (rightly
or wrongly (i'm not sure) is interpreting Component as the specialized
type in this context. BTW - this is a pointer no a reference.

....
Here is code that compiles - not sure if it does what you want. Note
that <: has special meaning in C++ (look up digraph) so make sure you
leave a space between < and ::.

#include <iostream>
#include <string>

using namespace std;

class Shutdown
{
virtual void begin()
{
cout << "shutdown" << endl;
exit(0);
}
};

Shutdown *gs;

template <template <class, class, classclass
Calling_Component, class T1, class T2, class T3>
class MyShutdown : public Shutdown
{
typedef Calling_Component<T1, T2, T3Caller;

Caller& mCaller;

public:
MyShutdown(Caller& rCaller)
: mCaller(rCaller)
{
}

void begin()
{
cout << "MyShutdown caller # " << mCaller.mnId << endl;
exit(0);
}
};

template <typename T1, typename T2, typename T3>
class Component
{
public:

Component(int n)
: mnId(n)
{
gs = new MyShutdown</* space */::Component, T1, T2, T3>(*this);
}

int mnId;
};
//} //namespace XX

int main()
{
Component<int, int, stringc(5);

MyShutdown< Component, int, int, strings(c);

s.begin();
}
Jun 8 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Neil Zanella | last post by:
Hello, I would like to ask how come the design of C++ includes std::pair. First of all I don't think many programmers would use it. For starters, what the first and second members are depends...
2
by: Bart Plessers \(artabel\) | last post by:
Hello, I need a style that defines -table cellspacing -table cellpading -alignment I tried <table class="TBLpageframe"> <tr class="TRpageframe">
5
by: CFG | last post by:
Is there a ready-to-use C++ smart pointer class working on top of COM reference counting mechanism. Did anyone manage to tailor one of the available smart pointer libs to handle COM objects? ...
13
by: jstanforth | last post by:
This is probably a very obvious question, but I'm not clear on what operators need to be implemented for std::map.find() to work. For example, I have a class MyString that wraps std::string, and...
3
by: Eric Lilja | last post by:
Hello, I was working on a program where I needed to take a vector storing objects of type std::string and convert each object to an int and store the ints in another vector. I decided that I should...
8
by: Joseph Turian | last post by:
Some function requires a vector<const foo*> argument. How can I cast a vector<foo*> to vector<const foo*>? Thanks! Joseph
4
by: Peted | last post by:
I have the following code public enum pdfFlags { PFD_DRAW_TO_WINDOW, PFD_DRAW_TO_BITMAP, PFD_SUPPORT_GDI, PFD_SUPPORT_OPENGL, PFD_GENERIC_ACCELERATED, PFD_GENERIC_FORMAT,
3
by: subramanian100in | last post by:
Given two types T1 and T2, we can create pair<T1, T2p(value1, value2); where value1 and value2 are of types T1 and T2 respectively. Suppose we want to assign a new pair<value to p. We can do...
6
by: not_a_commie | last post by:
I'm struggling here. Please help me complete this method: Type ToFuncType(Type owningType, Type result) { return typeof(Func<typeof(owningType), typeof(result)>); } Or more generally, given...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
jinu1996
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.