#include #include #include using namespace std; /* Explain here: * const vs. constexpr * Compile-time vs. might be later * static class members * scope resolution operator * Works on namespaces OR classes * typeof * trivially_destructible items * Basic types are * Stack allocated types usually are * Managed containers and such are not * Like string, vector, our dynamic array, etc * Is this going to run slow? * It'll compile slow! * Remember, each template instantiation can be independently optimized */ class scope_res_demo { public: constexpr static float value = 54.12; }; template class scope_res_with_template { public: constexpr static size_t tsize = sizeof(T); }; int main(){ cout << scope_res_demo::value << endl; cout << "Integer Size: " << scope_res_with_template::tsize << endl; cout << "Double Size: " << scope_res_with_template::tsize << endl; double x = 3.14; if(is_trivially_destructible::value){ cout << "x is trivially destructible\n"; } else { cout << "x is not trivially destructible\n"; } vector v; if(is_trivially_destructible::value){ cout << "v is trivially destructible\n"; } else { cout << "v is not trivially destructible\n"; } }