#include #include #include #include #ifdef _MSC_VER # include "vcl_msvc_warnings.h" #endif // ------------------------------------------------ template struct X { int x{1728}; X(); // declaration of static template member. static X *pl; }; template X::X() = default; // definition (not specialization) of static template member. template X *X::pl = nullptr; // explicit instantiation of class also instantiates statics. template struct X; // ------------------------------------------------ struct A { int x{0}; mutable int y{0}; A() = default; void f() { ++ x; } void g() const { ++ y; } }; // ------------------------------------------------ void vcl_test_implicit_instantiation(int n); int test_compiler_main(int /*argc*/,char* /*argv*/[]) { int result = 0; std::cout << "Testing static template member..." << std::flush; if ( X::pl == nullptr ) { std::cout << " PASSED" << std::endl; } else { std::cout << "**FAILED**" << std::endl; result = 1; } // If it links, it passed! std::cout << "Testing implicit instantiation..." << std::flush; vcl_test_implicit_instantiation(100); std::cout << " PASSED" << std::endl; return result; } struct mystery_type { mystery_type(); mystery_type(int, float); mystery_type(mystery_type const &); mystery_type &operator=(mystery_type const &); int a; float b; }; bool operator==(mystery_type const &, mystery_type const &); bool operator< (mystery_type const &, mystery_type const &); void vcl_test_implicit_instantiation(int n) { std::vector v; v.resize(n); for (int i=0; i > map_t; map_t m; for (int i=0; i