473,807 Members | 2,857 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple template arguments

In a recent thread "Why is overloading operator. (member operator)
forbidden", someone wrote a code like the following:

template <typename R, typename... Argtypes>
class gen_send {
private:
string funcname;
public:
R &operator()(Arg types... arguments) {
// serialize and send
// wait for return value, return value
}
};

Is that legal? I mean, is it legal to do the following:

template<typena me T, typename... ARGS>
void foo();

Does that mean that there could be many template parameters? If so,
how could I know how many template parameters were added? By template
specialization?

Thanks in advance,
KK.

May 14 '07 #1
5 3379
Kith Kanan schrieb:
In a recent thread "Why is overloading operator. (member operator)
forbidden", someone wrote a code like the following:

template <typename R, typename... Argtypes>
class gen_send {
private:
string funcname;
public:
R &operator()(Arg types... arguments) {
// serialize and send
// wait for return value, return value
}
};

Is that legal? I mean, is it legal to do the following:

template<typena me T, typename... ARGS>
void foo();
No, it was just an incomplete example.

--
Thomas
http://www.netmeister.org/news/learn2quote.html
May 14 '07 #2
On May 15, 12:39 am, Kith Kanan <fernando.a.gom e...@gmail.comw rote:
In a recent thread "Why is overloading operator. (member operator)
forbidden", someone wrote a code like the following:

template <typename R, typename... Argtypes>
class gen_send {
private:
string funcname;
public:
R &operator()(Arg types... arguments) {
// serialize and send
// wait for return value, return value
}

};

Is that legal?
Not in the current standard C++, but variadic template arguments are
most certainly included in the next C++ revision (it's already in the C
++09 draft)

Read the latest revision of the proposal itself:
http://www.open-std.org/jtc1/sc22/wg...2006/n2080.pdf
And the latest proposed wording: http://www.open-std.org/jtc1/sc22/wg...2007/n2242.pdf
The latest full C++09 draft: http://www.open-std.org/jtc1/sc22/wg...2006/n2134.pdf

- Sylvester

May 14 '07 #3
On May 14, 5:53 pm, "Thomas J. Gritzan" <Phygon_ANTIS.. .@gmx.de>
wrote:
Kith Kanan schrieb:
In a recent thread "Why is overloading operator. (member operator)
forbidden", someone wrote a code like the following:
template <typename R, typename... Argtypes>
class gen_send {
private:
string funcname;
public:
R &operator()(Arg types... arguments) {
// serialize and send
// wait for return value, return value
}
};
Is that legal? I mean, is it legal to do the following:
template<typena me T, typename... ARGS>
void foo();

No, it was just an incomplete example.

--
Thomashttp://www.netmeister. org/news/learn2quote.htm l
Now I feel ashamed... :P

Regards,
KK.

May 14 '07 #4
On May 14, 6:01 pm, sylvesterh...@g mail.com wrote:
On May 15, 12:39 am, Kith Kanan <fernando.a.gom e...@gmail.comw rote:
In a recent thread "Why is overloading operator. (member operator)
forbidden", someone wrote a code like the following:
template <typename R, typename... Argtypes>
class gen_send {
private:
string funcname;
public:
R &operator()(Arg types... arguments) {
// serialize and send
// wait for return value, return value
}
};
Is that legal?

Not in the current standard C++, but variadic template arguments are
most certainly included in the next C++ revision (it's already in the C
++09 draft)

Read the latest revision of the proposal itself:http://www.open-std.org/jtc1/sc22/wg...2006/n2080.pdf
And the latest proposed wording:http://www.open-std.org/jtc1/sc22/wg...2007/n2242.pdf
The latest full C++09 draft:http://www.open-std.org/jtc1/sc22/wg...2006/n2134.pdf

- Sylvester
Thanks for the information!

Regards,
KK

May 14 '07 #5
sy***********@g mail.com wrote:
::
:: Not in the current standard C++, but variadic template arguments
:: are
:: most certainly included in the next C++ revision (it's already in
:: the C ++09 draft)
::
:: Read the latest revision of the proposal itself:
:: http://www.open-std.org/jtc1/sc22/wg...2006/n2080.pdf
:: And the latest proposed wording:
:: http://www.open-std.org/jtc1/sc22/wg...2007/n2242.pdf
:: The latest full C++09 draft:
:: http://www.open-std.org/jtc1/sc22/wg...2006/n2134.pdf
::

And the *very* lastest draft (as of last week :-)

http://www.open-std.org/jtc1/sc22/wg...2007/n2284.pdf
Bo Persson
May 15 '07 #6

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

Similar topics

1
2225
by: bjam | last post by:
Hi, today I was able to abstract out into a separate xsl file a template that I specifically perform a call templates for, this worked with import no problem. However, when trying to do the same operation with a template that I use a match template on, IE was giving me the following error for the style sheet. Does anyone know how to import or include a match template versus a call named template? Thanks in advance for your help The...
8
11369
by: vpadial | last post by:
Hello, I want to build a library to help exporting c++ functions to a scripting languagge. The scripting language provides a function to register functions like: ANY f0() ANY f1(ANY) ANY f2(ANY, ANY) ANY f3(ANY, ANY, ANY)
14
2908
by: Bart Samwel | last post by:
Hi everybody, I would really like some help explaining this apparent discrepancy, because I really don't get it. Here is the snippet: void foo(int&); void foo(int const&); template<typename T>
2
3690
by: Michael Stembera | last post by:
Here is a very simple piece of code to repro this bug. template<typename T, int N> inline bool foo( void ) { return true; } template<typename T> inline bool foo<T, 1>( void ) { return false;
9
2229
by: jc | last post by:
Hi all, I have a data type to use that I can't modify its codes. E.g. This template data type is data_type. When I declare a variable of this data_type, I write as following: data_type(8, 2) x; // Declare a data_type variable Someone can confirm me that arguments in template data types must be
4
1958
by: Adam Nielsen | last post by:
Hi everyone, I've having some trouble trying to specialise a template. My original code, with one typename, worked: template <typename T> class MyClass { private: T data;
3
1983
by: Thomas Pajor | last post by:
Hey everybody, I got into serious trouble with template programming. I have a class which uses three template arguments, say template<typename Atype, typename Btype, typename Ctype> class some_class { };
8
2971
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 { // ... };
3
3136
by: nooneinparticular314159 | last post by:
I'm trying to do a template with specialization. I declare two templates, one of which looks like: template<int a, int b> struct MOO { enum{ VALUE = b == 0 ? a: MOO<some stuff>::VALUE };
0
9720
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9599
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10626
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10112
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6879
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3854
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.