2
0
Эх сурвалжийг харах

Added move semantics to cm_new which is the right way to do it (otherwise references would get actually passed by value)

Marko Pintera 12 жил өмнө
parent
commit
21ee092f7a

+ 2 - 2
CamelotUtility/Include/CmMemoryAllocator.h

@@ -94,7 +94,7 @@ namespace CamelotFramework
  */
  */
 #define MAKE_CM_NEW(z, n, unused)                                     \
 #define MAKE_CM_NEW(z, n, unused)                                     \
 	template<class Type, class Alloc BOOST_PP_ENUM_TRAILING_PARAMS(n, class T)>     \
 	template<class Type, class Alloc BOOST_PP_ENUM_TRAILING_PARAMS(n, class T)>     \
-	Type* cm_new(BOOST_PP_ENUM_BINARY_PARAMS(n, T, t) ) { \
+	Type* cm_new(BOOST_PP_ENUM_BINARY_PARAMS(n, T, &&t) ) { \
 		return new (cm_alloc<Alloc>(sizeof(Type))) Type(BOOST_PP_ENUM_PARAMS (n, t));     \
 		return new (cm_alloc<Alloc>(sizeof(Type))) Type(BOOST_PP_ENUM_PARAMS (n, t));     \
 	}
 	}
 
 
@@ -180,7 +180,7 @@ namespace CamelotFramework
 	// Create a new object with the general allocator and the specified parameters.
 	// Create a new object with the general allocator and the specified parameters.
 #define MAKE_CM_NEW(z, n, unused)                                     \
 #define MAKE_CM_NEW(z, n, unused)                                     \
 	template<class Type BOOST_PP_ENUM_TRAILING_PARAMS(n, class T)>     \
 	template<class Type BOOST_PP_ENUM_TRAILING_PARAMS(n, class T)>     \
-	Type* cm_new(BOOST_PP_ENUM_BINARY_PARAMS(n, T, t) ) { \
+	Type* cm_new(BOOST_PP_ENUM_BINARY_PARAMS(n, T, &&t) ) { \
 	return new (cm_alloc<GenAlloc>(sizeof(Type))) Type(BOOST_PP_ENUM_PARAMS (n, t));     \
 	return new (cm_alloc<GenAlloc>(sizeof(Type))) Type(BOOST_PP_ENUM_PARAMS (n, t));     \
 	}
 	}