473,730 Members | 4,274 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

template list prameter

Does that just not compile with vc++?
I found this in "template complete" and asked myself if this is just a
nice feature of some compilers, or if it is standard?

I can't install other compilers!

###########
#include <iostream>

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

template <typename T, ... list> inline
T const& max (T const& a, T const& b, list const& x)
{
return max (a, max(b,x));
}

int main(int argc, char* argv[])
{
std::cout << max<double>(1.0 , 3.0 ,4.0 ,8.0 ,0.0) << std::endl;
system("PAUSE") ;
return 0;
}

Feb 14 '06 #1
1 1347
eiji wrote:
Does that just not compile with vc++?
I found this in "template complete" and asked myself if this is just a
nice feature of some compilers, or if it is standard?
It's non-standard, AFAICT.

To add, I've never seen anything like this.

I can't install other compilers!

###########
#include <iostream>

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

template <typename T, ... list> inline
T const& max (T const& a, T const& b, list const& x)
{
return max (a, max(b,x));
}

int main(int argc, char* argv[])
{
std::cout << max<double>(1.0 , 3.0 ,4.0 ,8.0 ,0.0) << std::endl;
system("PAUSE") ;
return 0;
}


V
--
Please remove capital As from my address when replying by mail
Feb 14 '06 #2

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

Similar topics

3
2203
by: Gandu | last post by:
Could some C++ guru please help me? I have a very odd problem with respect templates and inheritance. I have templatized List class, from which I am inheriting to create a Stack class. All works fine till I have to create a Stack object - all sorts of error messages are generated. I have included source files below: The List class: #include "List.h" template <class T>
4
2580
by: Mat DeLong | last post by:
I have never been stuck on programming something before to the point I give up... this is a first. I am programming what should be something very easy in C++... using Templates. Here is the code, and the error I get: -------------- namespace LIST { template <typename T> struct Link; template <typename T> class List;
1
2124
by: darkstorm | last post by:
Please check this program...When I compiles it in VC.net, it gives the following error: =============== Common\Lib\PList.h(115): error C2440: '=' : cannot convert from 'ListNode *' to 'List<T>::ListNode *' with Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast project\Source\Levelmgr.cpp(198) : while compiling
11
3600
by: cyberdave | last post by:
Someone please help me! I have a template class like this: -------------------------------------------------- template<typename T> class List { public:
8
3059
by: Plissken.s | last post by:
I have a template function which print out the content of a list: The following compiles: void PrintInt2 (int i) { cout << i << " "; } template <class T> void printList(T& list) {
2
1977
by: Greg Buchholz | last post by:
/* I've been experimenting with some generic/polytypic programs, and I've stumbled on to a problem that I can't quite figure out. In the program below, I'm trying to define a generic version of "transform" which works not only on lists, but lists of list, lists of lists of lists, etc. I'm calling it "fmap" and it passes around actual lists instead of iterators (for now). In order to get it to work, I thought I'd have one templated...
45
2909
by: charles.lobo | last post by:
Hi, I have recently begun using templates in C++ and have found it to be quite useful. However, hearing stories of code bloat and assorted problems I decided to write a couple of small programs to check. What I expected was that there would be minor code bloat and some speed improvement when using templates. However... I wrote a basic list container (using templates), and a list container (using virtual derived classes). I also tried...
8
287
by: Konstantin | last post by:
I have two possible implementations of my class: template <typename T> class MyContainer { public: typedef typename std::set<T>::const_iterator const_iterator; void add( T id ) { data.insert(id); } void remove( T id ) { data.erase(id); } private:
7
5772
by: QiongZ | last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it compiled no problem. But I can't find the what the problem is with templates? Please help. The main is in test-linked-list.cpp. There are two template classes. One is List1, the other one is ListNode. The codes are below: // test-linked-list.cpp :...
0
8943
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
8770
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
9442
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
9301
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9176
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...
1
6725
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4801
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3257
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
3
2175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.