From 5a35640912a4848b48e1a76121efd37f7df387f5 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Thu, 30 Jul 2015 10:36:49 -0400 Subject: Added validat0.cpp and moved bit tests into it. Provided tests for SafeConvert. Removed "using namespace std" from test sources (auto_ptr causes a collision becuase std:: provides it in C++03, but CryptoPP:: provides it in C++11 --- smartptr.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'smartptr.h') diff --git a/smartptr.h b/smartptr.h index 30d996fa..5b275c2b 100644 --- a/smartptr.h +++ b/smartptr.h @@ -7,25 +7,27 @@ NAMESPACE_BEGIN(CryptoPP) -// 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. +// Hack ahead. Apple's standard library does not have C++'s unique_ptr in C++11. We can't +// test for unique_ptr directly because some of the non-Apple Clangs on OS X 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 +# if defined(__clang__) +# if (__has_include()) +# define CRYPTOPP_HAVE_UNIQUE_PTR 1 # endif +# else +# define CRYPTOPP_HAVE_UNIQUE_PTR 1 +# endif #endif +// The result of below is a CryptoPP::auto_ptr in both cases #ifdef CRYPTOPP_HAVE_UNIQUE_PTR -// use unique_ptr instead of auto_ptr -template + template using std::auto_ptr = std::unique_ptr; #else -// do nothing; use auto_ptr + using std::auto_ptr; #endif template class simple_ptr @@ -79,7 +81,7 @@ public: T *old_p = m_p; m_p = 0; return old_p; - } + } void reset(T *p = 0); @@ -175,7 +177,7 @@ protected: }; template counted_ptr::counted_ptr(T *p) - : m_p(p) + : m_p(p) { if (m_p) m_p->m_referenceCount = 1; -- cgit v1.2.1