From 4a41a65600fa3e6383f367a485f22eadfab0e52b Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Tue, 3 Feb 2015 15:05:21 -0800 Subject: [PATCH] Fixed make_unique to work with C++14+ compilers 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 Reviewed-on: https://gerrit.iotivity.org/gerrit/299 Tested-by: jenkins-iotivity Reviewed-by: Ossama Othman Reviewed-by: Sudarshan Prasad --- resource/include/OCUtilities.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/resource/include/OCUtilities.h b/resource/include/OCUtilities.h index a736820..aca25e9 100644 --- a/resource/include/OCUtilities.h +++ b/resource/include/OCUtilities.h @@ -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 std::unique_ptr make_unique(XS&& ...xs) @@ -62,15 +62,13 @@ namespace OC { return std::unique_ptr(new T(std::forward(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); -- 2.7.4