I've started to pick up this pattern:
template<typename T> struct DefaultInitialize { DefaultInitialize():m_value(T()){} // ... conversions, assignments, etc .... }; So that when I have classes with primitive members, I can set them to be initialized to 0 on construction:
struct Class { ... DefaultInitialize<double> m_double; ... }; The reason I do this is to avoid having to remember to initialize the member in each constructor (if there are multiple constructors). I'm trying to figure out if:
- This is a valid pattern?
- I am using the right terminology?