Skip to content

Instantly share code, notes, and snippets.

@thiagomg
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagomg/c444563a5efd275df823 to your computer and use it in GitHub Desktop.
Save thiagomg/c444563a5efd275df823 to your computer and use it in GitHub Desktop.
Templates e geração de código
class NonTemplated {
int value;
public:
using value_type = int;
NonTemplated(int a) : value(a) {}
int sum(int a) { return value + a; }
};
template <typename T>
class Templated {
T value;
public:
using value_type = T;
Templated(T a) : value(a) {}
T sum(T a) { return value + a; }
};
//.....
NonTemplated nt{1};
Templated<int> ti{1};
Templated<double> td{1.0};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment