From 9f5fe452c9b66fb8e5d66f8d939d975c8393e81d Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Fri, 23 Nov 2012 14:16:23 +0000 Subject: [PATCH] Give shared_ptr the same treatment. Here I have defined my own test for the feature. It's not an extensive test but it checks for the presence of the class. --- cmake/Modules/CheckCXX11Features.cmake | 1 + .../CheckCXX11Features/cxx11-test-shared_ptr.cpp | 7 +++++++ .../PolyVoxCore/Impl/CompilerCapabilities.h.in | 2 ++ .../PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h | 13 ++++++++----- 4 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-shared_ptr.cpp diff --git a/cmake/Modules/CheckCXX11Features.cmake b/cmake/Modules/CheckCXX11Features.cmake index 0699f48e..5373ba6a 100644 --- a/cmake/Modules/CheckCXX11Features.cmake +++ b/cmake/Modules/CheckCXX11Features.cmake @@ -130,3 +130,4 @@ cxx11_check_feature("rvalue-references" HAS_CXX11_RVALUE_REFERENCES) cxx11_check_feature("sizeof_member" HAS_CXX11_SIZEOF_MEMBER) cxx11_check_feature("static_assert" HAS_CXX11_STATIC_ASSERT) cxx11_check_feature("variadic_templates" HAS_CXX11_VARIADIC_TEMPLATES) +cxx11_check_feature("shared_ptr" HAS_CXX11_SHARED_PTR) diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-shared_ptr.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-shared_ptr.cpp new file mode 100644 index 00000000..2d9c6bd1 --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-shared_ptr.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + std::shared_ptr test; + return 0; +} diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in b/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in index 0a5cfed1..5518dfb2 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in @@ -7,4 +7,6 @@ #cmakedefine HAS_CXX11_CSTDINT_H +#cmakedefine HAS_CXX11_SHARED_PTR + #endif diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h b/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h index 0f9c832e..996414ca 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h @@ -67,9 +67,6 @@ freely, subject to the following restrictions: //To support old (pre-vc2010) Microsoft compilers we use boost to replace the //std::shared_ptr and potentially other C++0x features. To use this capability you //will need to make sure you have boost installed on your system. - #include - #define polyvox_shared_ptr boost::shared_ptr - #include #define polyvox_function boost::function @@ -80,8 +77,6 @@ freely, subject to the following restrictions: #else //We have a decent compiler - use real C++0x features #include - #include - #define polyvox_shared_ptr std::shared_ptr #define polyvox_function std::function #define polyvox_bind std::bind #define polyvox_placeholder_1 std::placeholders::_1 @@ -115,4 +110,12 @@ freely, subject to the following restrictions: using boost::uint32_t; #endif +#if defined(HAS_CXX11_SHARED_PTR) + #include + #define polyvox_shared_ptr std::shared_ptr +#else + #include + #define polyvox_shared_ptr boost::shared_ptr +#endif + #endif