Use unique_ptr if available; else fall back to auto_ptr
authorDan Breslau <dbreslau@painless-security.com>
Fri, 28 Oct 2016 20:46:33 +0000 (16:46 -0400)
committerDan Breslau <dbreslau@painless-security.com>
Fri, 28 Oct 2016 20:46:33 +0000 (16:46 -0400)
mech_eap/util_shib.cpp

index f919fc0..875c9a5 100644 (file)
@@ -66,6 +66,7 @@
 #include <shibresolver/resolver.h>
 
 #include <sstream>
+#include <memory>
 
 using namespace shibsp;
 using namespace shibresolver;
@@ -78,6 +79,14 @@ using namespace opensaml;
 using namespace xercesc;
 #endif
 
+// Use unique_ptr where available; auto_ptr otherwise.
+#if __cplusplus > 199711L
+#define UNIQUE_OR_AUTO_PTR unique_ptr
+#else
+#define UNIQUE_OR_AUTO_PTR auto_ptr
+#endif
+
+
 gss_eap_shib_attr_provider::gss_eap_shib_attr_provider(void)
 {
     m_initialized = false;
@@ -123,7 +132,7 @@ gss_eap_shib_attr_provider::initWithGssContext(const gss_eap_attr_ctx *manager,
     if (!gss_eap_attr_provider::initWithGssContext(manager, gssCred, gssCtx))
         return false;
 
-    unique_ptr<ShibbolethResolver> resolver(ShibbolethResolver::create());
+    UNIQUE_OR_AUTO_PTR<ShibbolethResolver> resolver(ShibbolethResolver::create());
 
     /*
      * For now, leave ApplicationID defaulted.