template list prameter

E

eiji

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;
}
 
V

Victor Bazarov

eiji said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,216
Latest member
topweb3twitterchannels

Latest Threads

Top