Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Variadic template example
//g++ 5.4.0 // https://eli.thegreenplace.net/2014/variadic-templates-in-c/ // Demonstration of a variadic template #include <iostream> template<typename T> T adder(T v) { return v; } template<typename T, typename... Args> T adder(T first, Args... args) { return first + adder(args...); } int main() { long sum = adder(1, 2, 3, 8, 7); std::string s1 = "x", s2 = "aa", s3 = "bb", s4 = "yy"; std::string ssum = adder(s1, s2, s3, s4); std::cout << "Sum of parameters=" << sum << std::endl; std::cout << "Concatenation of strings=" << ssum << std::endl; }
run
|
edit
|
history
|
help
0
Scemo
alma
begin_end.cpp
Pointer to class members
4
static property
const_cast
temporaries and move constructor
My billing system
1234