473,397 Members | 2,033 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,397 software developers and data experts.

List parameters

Hi,

I try this code:

template <typename Tinline
T const& max(T const& a, T const& b)
{
return a<b?b:a;
}

template <typename T, ... listinline
T const& max(T const& a, T const& b, list const& x)
{
return max(a, max(b, x));
}
But it not compile.
I have this message:
"error: expected identifier before '...' token"

I saw this sample in book "c++ templates: the complete guide"
i use wxWidgets with gcc compiler.

Is this code legal? is it compile?
If no how use list parameters in template?

Thunks
Oct 21 '06 #1
4 1280
On Sun, 22 Oct 2006 02:06:20 +0200 in comp.lang.c++,
us**@domain.invalid wrote,
> template <typename T, ... listinline
T const& max(T const& a, T const& b, list const& x)
{
return max(a, max(b, x));
}
No, the ... is not at all allowed there.
This is from chapter 13, "Future Directions", where the authors are
discussing things that don't exist yet, but might in the future,
right???

Oct 22 '06 #2
David Harmon a écrit :
On Sun, 22 Oct 2006 02:06:20 +0200 in comp.lang.c++,
us**@domain.invalid wrote,
>> template <typename T, ... listinline
T const& max(T const& a, T const& b, list const& x)
{
return max(a, max(b, x));
}


No, the ... is not at all allowed there.
This is from chapter 13, "Future Directions", where the authors are
discussing things that don't exist yet, but might in the future,
right???
Ok,
Thunks.

I try to do it with typeListe technique in modern c++.

But there'is function ellipsis like:

void f(int ...);

f(1, 2, 3);
f(45, 68 ,2 ,64 ,3598);

that compile. But it's not easy to use argument of this function.

Oct 22 '06 #3
Lahsen wrote:
>
But there'is function ellipsis like:

void f(int ...);

f(1, 2, 3);
f(45, 68 ,2 ,64 ,3598);

that compile. But it's not easy to use argument of this function.
That's a runtime thing which isn't type-safe at all.
It should be avoided.
Oct 22 '06 #4
us**@domain.invalid wrote:
Hi,

I try this code:

template <typename Tinline
T const& max(T const& a, T const& b)
{
return a<b?b:a;
}

template <typename T, ... listinline
T const& max(T const& a, T const& b, list const& x)
{
return max(a, max(b, x));
}
But it not compile.
You might want to play around with variadic templates, a proposal for
the next C++ standard which will allow what you want.
There is already a patch to implement it in GCC.
Oct 22 '06 #5

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

Similar topics

2
by: Jeff Thur | last post by:
I am running a SQL Stored Procedure that will give the user a count of how many records are in the database as per certain criteria. I'm using the Execute Scalar Method. I have no problem passing...
7
by: ritchie | last post by:
Hi, I am writing to ask for some info with a program I am trying out. I am teaching myself linked lists in C. I have a linked list (see code below), and I accept user input which is the...
4
by: JH | last post by:
Fairly new to c# so please forgive any simple oversights. I'm developing a console app that loads dll assemblies at run time. The app scans a "plugin" directory for these dlls. Each dll is loaded...
5
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1);...
5
by: tshad | last post by:
I can't seem to find where to reset the parameter list. Dim objCmd as New SqlCommand(CommandText,objConn) with objCmd.Parameters .Add("@StateCode",SqlDbType.Char,2).value = ByState.SelectedValue...
2
by: R2d2Rabeau | last post by:
Hi, How can I pass values from a List as stored procedure parameters? name= "Smith", age = 21 name="Brown", age =46 name="White", age=28 ... // data added to the List
0
by: Atos | last post by:
SINGLE-LINKED LIST Let's start with the simplest kind of linked list : the single-linked list which only has one link per node. That node except from the data it contains, which might be...
0
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: List of autostart locations Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list all the autostart locations for windows? Ans: Here is...
3
by: kirschey | last post by:
I have read the other posts on this subject, but I am still having issues. I have a few combo, and one multiselect list box for States delimiting. I am trying to feed a query based on this info. ...
3
by: semomaniz | last post by:
I have a ajax reorderlist that displays the contents with out any problems but when i drag and reorder the list nothing happens, i get a postback and the same initial list is displayed, seems like my...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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...
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...
0
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,...
0
isladogs
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 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.