Created
December 10, 2014 00:32
-
-
Save bithavoc/a2f53352eac4a1202c35 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <locale> | |
#include <regex> | |
using namespace std; | |
class Node { | |
public: | |
Node(const string& name) : name(name) { | |
cout << "grid " << this->name << " initialized" << endl; | |
} | |
Node(const Node& original) : name(original.name) { | |
cout << "grid " << this->name <<" copied" << endl; | |
} | |
const string getName() const noexcept { | |
return name; | |
} | |
private: | |
string name; | |
}; | |
void print(Node& value) { | |
cout << "Printing " << value.getName() << endl; | |
} | |
template<typename T> | |
void printValue(T&& val) { | |
print(val); | |
} | |
template< typename T1> | |
void printValues(T1&& arg1) { | |
printValue(forward<T1>(arg1)); | |
} | |
template< typename T1, typename... Tn> | |
void printValues(T1&& arg1, Tn&&... args) { | |
printValue(forward<T1>(arg1)); | |
printValues(forward<Tn>(args)...); | |
} | |
int main() { | |
printValues(Node("first"), Node("second"), Node("third")); | |
return 0; | |
} | |
/** | |
$ ./main | |
grid first initialized | |
grid second initialized | |
grid third initialized | |
Printing first | |
Printing second | |
Printing third | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment