Fixed make_unique to work with C++14+ compilers
authorErich Keane <erich.keane@intel.com>
Tue, 3 Feb 2015 23:05:21 +0000 (15:05 -0800)
committerSudarshan Prasad <sudarshan.prasad@intel.com>
Fri, 6 Feb 2015 03:22:43 +0000 (03:22 +0000)
Previous solution didn't correctly import the make_unique from
C++14/1z when using the new compiler.  This ensures that OC::make_unique
will always work correctly.

Change-Id: Ibb7456f6375c5c16553bb76c71646ec911190c0f
Signed-off-by: Erich Keane <erich.keane@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/299
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Ossama Othman <ossama.othman@intel.com>
Reviewed-by: Sudarshan Prasad <sudarshan.prasad@intel.com>
resource/include/OCUtilities.h

index a736820..aca25e9 100644 (file)
@@ -53,8 +53,8 @@ namespace OC {
 
 /* The C++11 standard unfortunately forgot to provide make_unique<>! However, if we're
 using C++14 or later, we want to take the standard library's implementation: */
-#if defined(__cplusplus) && __cplusplus < 201300
 namespace OC {
+#if defined(__cplusplus) && __cplusplus < 201300
 
     template<typename T, typename ...XS>
     std::unique_ptr<T> make_unique(XS&& ...xs)
@@ -62,15 +62,13 @@ namespace OC {
         return std::unique_ptr<T>(new T(std::forward<XS>(xs)...));
     }
 
-} // namespace OC
 #else
     using std::make_unique;
 #endif
+} // namespace OC
 
 namespace OC {
 
-    using OC::make_unique;
-
     /* Examine an OCStackResult, and either forward its value or raise an exception: */
     OCStackResult result_guard(const OCStackResult r);