Last active
August 29, 2015 14:01
-
-
Save themalkolm/b42c62fa0fad06e62730 to your computer and use it in GitHub Desktop.
This file contains 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
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