From ae0984b4b17e6bda2231da23c190033df369e5c0 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 29 Jul 2015 13:37:52 -0400 Subject: [PATCH] Cleaned up tests for OS X, TR1 names spaces and ancient versus modern libstdc++ and libc++. Thanks to Jonathan Wakely for devising the clever test --- smartptr.h | 38 +++++++++++++++++++------------------- stdcpp.h | 21 +++++---------------- 2 files changed, 24 insertions(+), 35 deletions(-) diff --git a/smartptr.h b/smartptr.h index 3ddfc9a9..30d996fa 100644 --- a/smartptr.h +++ b/smartptr.h @@ -7,26 +7,26 @@ NAMESPACE_BEGIN(CryptoPP) -#if 0 -// This must be kept in sync with stdcpp.h because is included based on the same logic. -#if ((__cplusplus >= 201103L) || (_MSC_VER >= 1600)) && !defined(__clang__) -# include - template - using auto_ptr = std::unique_ptr; -#elif defined(__clang__) -# if (__has_include()) -# include - using std::auto_ptr; -# endif -#elif (__cplusplus < 201103L) -# include - using std::auto_ptr; -#else -# include - template - using auto_ptr = std::unique_ptr; +// Hack ahead. Apple's standard library does not have C++'s unique_ptr. We can't test +// for unique_ptr directly because some of the Clangs on Apple fail the same way. +// However, modern standard libraries have , so we test for it instead. +// Thanks to Jonathan Wakely for devising the clever test for modern/ancient versions. + +#if (__cplusplus >= 201103L) || (_MSC_VER >= 1600) +# if defined(__clang__) && (__has_include()) +# define CRYPTOPP_HAVE_UNIQUE_PTR 1 +# else +# define CRYPTOPP_HAVE_UNIQUE_PTR 1 +# endif +#endif + +#ifdef CRYPTOPP_HAVE_UNIQUE_PTR +// use unique_ptr instead of auto_ptr +template + using std::auto_ptr = std::unique_ptr; +#else +// do nothing; use auto_ptr #endif -#endif // 0 template class simple_ptr { diff --git a/stdcpp.h b/stdcpp.h index f5b62da6..517d1089 100644 --- a/stdcpp.h +++ b/stdcpp.h @@ -12,28 +12,17 @@ #include #include -// http://marshall.calepin.co/c-and-xcode-46.html. Apple does some wonky stuff with -// , auto_ptr and unique_ptr. Apple's built-in Clang behaves -// differently than a LLVM downloaded and compiled CLang. So we fall back to Clang's -// __has_include (http://clang.llvm.org/docs/LanguageExtensions.html#id3). -// This must be kept in sync with smartptr.h because auto_ptr and unique_ptr are -// brought in based on the same logic. -#if ((__cplusplus >= 201103L) || (_MSC_VER >= 1600)) && !defined(__clang__) -# include -#elif defined(__clang__) -# if (__has_include()) -# include -# endif -#elif (__cplusplus < 201103L) -# include -#else -# include +// http://marshall.calepin.co/c-and-xcode-46.html. +// This include is needed so we can pickup _LIBCPP_VERSION, if needed. +#if defined(__APPLE__) +# include #endif #include #include #include #include +#include #include #include #include