Skip to content

Instantly share code, notes, and snippets.

@themalkolm
Last active August 29, 2015 14:01
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 themalkolm/b42c62fa0fad06e62730 to your computer and use it in GitHub Desktop.
Save themalkolm/b42c62fa0fad06e62730 to your computer and use it in GitHub Desktop.
template <typename T, T def>
struct primitive_t : is_lexical_value<T> {
typedef T value_type;
primitive_t() : t(def) {}
primitive_t(T t) : t(t) {}
primitive_t& operator=(T a_t) {
t = a_t;
return *this;
}
operator T() const { return t; }
private:
T t;
};
// example
typedef primitive_t<int, 0> angle_t;
struct Camera {
angle_t angle; // will be 0 by default :D
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment