// // 2.7.decltype.cpp // chapter 2 language usability // modern cpp tutorial // // created by changkun at changkun.de // https://github.com/changkun/modern-cpp-tutorial // #include #include int main() { auto x = 1; auto y = 2; decltype(x+y) z = 3; if (std::is_same::value) std::cout << "type x == int" << std::endl; if (std::is_same::value) std::cout << "type z == float" << std::endl; if (std::is_same::value) std::cout << "type z == type x" << std::endl; return 0; }