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;
} 1 1345
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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>
|
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;
|
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
|
by: cyberdave |
last post by:
Someone please help me!
I have a template class like this:
--------------------------------------------------
template<typename T>
class List
{
public:
|
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) {
| |
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...
|
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...
|
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:
|
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 :...
|
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...
|
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,...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |