In addition to the good quantdev answer I supported, I would like to provide a little more information here (which would not fit the comment).
Here is the corresponding C ++ 11 program that demonstrates whether the implementation supports the GC interface:
#include <iostream> #include <memory> int main() { #ifdef __STDCPP_STRICT_POINTER_SAFETY__ std::cout << __STDCPP_STRICT_POINTER_SAFETY__ << '\n'; #endif switch (std::get_pointer_safety()) { case std::pointer_safety::relaxed: std::cout << "relaxed\n"; break; case std::pointer_safety::preferred: std::cout << "preferred\n"; break; case std::pointer_safety::strict: std::cout << "strict\n"; break; } }
Output:
relaxed
means the implementation has a trivial implementation that does nothing.
LibC ++ output:
relaxed
VS-2015 Outputs:
relaxed
gcc 5.0:
prog.cc: In function 'int main()': prog.cc:10:13: error: 'get_pointer_safety' is not a member of 'std' switch (std::get_pointer_safety()) ^
Howard hinnant
source share