summaryrefslogtreecommitdiff
path: root/smartptr.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2015-07-30 10:36:49 -0400
committerJeffrey Walton <noloader@gmail.com>2015-07-30 10:36:49 -0400
commit5a35640912a4848b48e1a76121efd37f7df387f5 (patch)
tree914f0f8da1ad392e9cf8ac7986913a20c3177c0a /smartptr.h
parent264018e8ec9ee3fdd5fe7d32f91dd91f8dffc6bb (diff)
downloadcryptopp-git-5a35640912a4848b48e1a76121efd37f7df387f5.tar.gz
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
Diffstat (limited to 'smartptr.h')
-rw-r--r--smartptr.h26
1 files changed, 14 insertions, 12 deletions
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 <forward_list>, 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 <forward_list>, 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(<forward_list>))
-# define CRYPTOPP_HAVE_UNIQUE_PTR 1
-# else
-# define CRYPTOPP_HAVE_UNIQUE_PTR 1
+# if defined(__clang__)
+# if (__has_include(<forward_list>))
+# 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<typename T>
+ template<typename T>
using std::auto_ptr = std::unique_ptr<T>;
#else
-// do nothing; use auto_ptr
+ using std::auto_ptr;
#endif
template <class T> 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 <class T> counted_ptr<T>::counted_ptr(T *p)
- : m_p(p)
+ : m_p(p)
{
if (m_p)
m_p->m_referenceCount = 1;