Browse Source

Using std static_assert and type traits

Marko Pintera 12 years ago
parent
commit
4547c9fa58

+ 0 - 1
CamelotCore/Include/CmCommandQueue.h

@@ -3,7 +3,6 @@
 #include "CmPrerequisites.h"
 #include "CmAsyncOp.h"
 #include "CmCommonEnums.h"
-#include "boost/function.hpp"
 #include <functional>
 
 namespace CamelotFramework

+ 0 - 1
CamelotCore/Include/CmCoreObject.h

@@ -2,7 +2,6 @@
 
 #include "CmPrerequisites.h"
 #include "CmAsyncOp.h"
-#include <boost/function.hpp>
 #include <boost/preprocessor.hpp>
 
 namespace CamelotFramework

+ 0 - 1
CamelotCore/Include/CmRenderSystem.h

@@ -49,7 +49,6 @@ THE SOFTWARE.
 #include "CmPlane.h"
 #include "CmModule.h"
 
-#include "boost/function.hpp"
 #include "boost/signal.hpp"
 
 namespace CamelotFramework

+ 5 - 7
CamelotCore/Include/CmSceneObject.h

@@ -9,8 +9,6 @@
 #include "CmGameObjectManager.h"
 #include "CmGameObject.h"
 
-#include "boost/static_assert.hpp"
-
 namespace CamelotFramework
 {
 	class CM_EXPORT SceneObject : public GameObject
@@ -218,7 +216,7 @@ namespace CamelotFramework
 		template <typename T>
 		GameObjectHandle<T> addComponent()
 		{
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::Component, T>::value), "Specified type is not a valid Component.");
+			static_assert((std::is_base_of<CamelotFramework::Component, T>::value), "Specified type is not a valid Component.");
 
 			std::shared_ptr<T> gameObject(new (cm_alloc<T, PoolAlloc>()) T(mThisHandle), &cm_delete<PoolAlloc, T>, StdAlloc<PoolAlloc>());
 
@@ -235,7 +233,7 @@ namespace CamelotFramework
 		template<class Type BOOST_PP_ENUM_TRAILING_PARAMS(n, class T)>					\
 		GameObjectHandle<Type> addComponent(BOOST_PP_ENUM_BINARY_PARAMS(n, T, &&t) )	\
 		{																				\
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::Component, Type>::value),  \
+			static_assert((std::is_base_of<CamelotFramework::Component, Type>::value),  \
 				"Specified type is not a valid Component.");										\
 																									\
 			std::shared_ptr<Type> gameObject(new (cm_alloc<Type, PoolAlloc>()) Type(mThisHandle,	\
@@ -274,7 +272,7 @@ namespace CamelotFramework
 		template <typename T>
 		GameObjectHandle<T> getComponent()
 		{
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::Component, T>::value), 
+			static_assert((std::is_base_of<CamelotFramework::Component, T>::value), 
 				"Specified type is not a valid Component.");
 
 			return static_object_cast<T>(getComponent(T::getRTTIStatic()->getRTTIId()));
@@ -292,7 +290,7 @@ namespace CamelotFramework
 		template <typename T>
 		bool hasComponent()
 		{
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::Component, T>::value), 
+			static_assert((std::is_base_of<CamelotFramework::Component, T>::value), 
 				"Specified type is not a valid Component.");
 
 			return hasComponent(T::getRTTIStatic()->getRTTIId());
@@ -334,7 +332,7 @@ namespace CamelotFramework
 		template <typename T>
 		static std::shared_ptr<T> createEmptyComponent()
 		{
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::Component, T>::value), "Specified type is not a valid Component.");
+			static_assert((std::is_base_of<CamelotFramework::Component, T>::value), "Specified type is not a valid Component.");
 
 			std::shared_ptr<T> gameObject(new (cm_alloc<T, PoolAlloc>()) T(), &cm_delete<PoolAlloc, T>, StdAlloc<PoolAlloc>());
 			GameObjectHandle<T>(GameObjectManager::instance().registerObject(gameObject));

+ 0 - 1
CamelotUtility/Include/CmBinarySerializer.h

@@ -1,7 +1,6 @@
 #pragma once
 
 #include <unordered_map>
-#include <boost/function.hpp>
 
 #include "CmPrerequisitesUtil.h"
 #include "CmRTTIField.h"

+ 1 - 4
CamelotUtility/Include/CmException.h

@@ -2,9 +2,6 @@
 
 #include "CmPrerequisitesUtil.h"
 
-#include <boost/static_assert.hpp>
-#include <boost/type_traits.hpp>
-
 #if defined(_MSC_VER)
 #undef __PRETTY_FUNCTION__
 #define __PRETTY_FUNCTION__ __FUNCSIG__
@@ -133,7 +130,7 @@ namespace CamelotFramework
 #ifndef CM_EXCEPT
 #define CM_EXCEPT(type, desc)	\
 	{                           \
-	BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::Exception, type##>::value), "Invalid exception type (" #type ") for CM_EXCEPT macro. It needs to derive from CamelotFramework::Exception."); \
+	static_assert((std::is_base_of<CamelotFramework::Exception, type##>::value), "Invalid exception type (" #type ") for CM_EXCEPT macro. It needs to derive from CamelotFramework::Exception."); \
 	throw type##(desc, __PRETTY_FUNCTION__, __FILE__, __LINE__); \
 	}
 #endif

+ 0 - 2
CamelotUtility/Include/CmRTTIField.h

@@ -2,9 +2,7 @@
 
 #include <string>
 
-#include <boost/function.hpp>
 #include <boost/any.hpp>
-#include <boost/static_assert.hpp>
 #include <type_traits>
 
 #include "CmPrerequisitesUtil.h"

+ 2 - 2
CamelotUtility/Include/CmRTTIPlainField.h

@@ -102,7 +102,7 @@ namespace CamelotFramework
 		{
 			int typeId = RTTIPlainType<DataType>::id; // Just making sure provided type has a type ID
 
-			BOOST_STATIC_ASSERT_MSG((RTTIPlainType<DataType>::hasDynamicSize != 0 || (sizeof(DataType) <= 255)), 
+			static_assert((RTTIPlainType<DataType>::hasDynamicSize != 0 || (sizeof(DataType) <= 255)), 
 				"Trying to create a plain RTTI field with size larger than 255. In order to use larger sizes for plain types please specialize " \
 				" RTTIPlainType, set hasDynamicSize to true.");
 
@@ -129,7 +129,7 @@ namespace CamelotFramework
 		{
 			int typeId = RTTIPlainType<DataType>::id; // Just making sure provided type has a type ID
 
-			BOOST_STATIC_ASSERT_MSG((RTTIPlainType<DataType>::hasDynamicSize != 0 || (sizeof(DataType) <= 255)), 
+			static_assert((RTTIPlainType<DataType>::hasDynamicSize != 0 || (sizeof(DataType) <= 255)), 
 				"Trying to create a plain RTTI field with size larger than 255. In order to use larger sizes for plain types please specialize " \
 				" RTTIPlainType, set hasDynamicSize to true.");
 

+ 14 - 16
CamelotUtility/Include/CmRTTIType.h

@@ -4,8 +4,6 @@
 #include <algorithm>
 #include <unordered_map>
 
-#include <boost/type_traits.hpp>
-#include <boost/static_assert.hpp>
 #include <boost/preprocessor/punctuation/comma.hpp>
 
 #include "CmPrerequisitesUtil.h"
@@ -102,7 +100,7 @@ namespace CamelotFramework
 		template <class ObjectType, class DataType>
 		void setReflectableValue(ObjectType* object, const String& name, DataType& value)
 		{
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
+			static_assert((std::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
 				"Invalid data type for complex field. It needs to derive from CamelotFramework::IReflectable.");
 
 			RTTIField* genericField = findField(name);
@@ -115,7 +113,7 @@ namespace CamelotFramework
 		template <class ObjectType, class DataType>
 		void setReflectableArrayValue(ObjectType* object, const String& name, UINT32 index, DataType& value)
 		{
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
+			static_assert((std::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
 				"Invalid data type for complex field. It needs to derive from CamelotFramework::IReflectable.");
 
 			RTTIField* genericField = findField(name);
@@ -139,7 +137,7 @@ namespace CamelotFramework
 		template <class ObjectType, class DataType>
 		void setReflectablePtrValue(ObjectType* object, const String& name, std::shared_ptr<DataType> value)
 		{
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
+			static_assert((std::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
 				"Invalid data type for complex field. It needs to derive from CamelotFramework::IReflectable.");
 
 			RTTIField* genericField = findField(name);
@@ -152,7 +150,7 @@ namespace CamelotFramework
 		template <class ObjectType, class DataType>
 		void setReflectablePtrArrayValue(ObjectType* object, const String& name, UINT32 index, std::shared_ptr<DataType> value)
 		{
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
+			static_assert((std::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
 				"Invalid data type for complex field. It needs to derive from CamelotFramework::IReflectable.");
 
 			RTTIField* genericField = findField(name);
@@ -525,10 +523,10 @@ namespace CamelotFramework
 		{
 			using namespace std::placeholders;
 
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::RTTIType<Type, BaseType, MyRTTIType>, InterfaceType>::value), 
+			static_assert((std::is_base_of<CamelotFramework::RTTIType<Type, BaseType, MyRTTIType>, InterfaceType>::value), 
 				"Class with the get/set methods must derive from CamelotFramework::RTTIType.");
 
-			BOOST_STATIC_ASSERT_MSG(!(boost::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
+			static_assert(!(std::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
 				"Data type derives from IReflectable but it is being added as a plain field.");
 
 			addPlainField<ObjectType, DataType>(name, uniqueId, 
@@ -569,10 +567,10 @@ namespace CamelotFramework
 		{
 			using namespace std::placeholders;
 
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::RTTIType<Type, BaseType, MyRTTIType>, InterfaceType>::value), 
+			static_assert((std::is_base_of<CamelotFramework::RTTIType<Type, BaseType, MyRTTIType>, InterfaceType>::value), 
 				"Class with the get/set methods must derive from CamelotFramework::RTTIType.");
 
-			BOOST_STATIC_ASSERT_MSG(!(boost::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
+			static_assert(!(std::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
 				"Data type derives from IReflectable but it is being added as a plain field.");
 
 			addPlainArrayField<ObjectType, DataType>(name, uniqueId, 
@@ -651,7 +649,7 @@ namespace CamelotFramework
 		template<class ObjectType, class DataType>
 		void addReflectableField(const String& name, UINT32 uniqueId, boost::any getter, boost::any setter, UINT64 flags)
 		{
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
+			static_assert((std::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
 				"Invalid data type for complex field. It needs to derive from CamelotFramework::IReflectable.");
 
 			RTTIReflectableField<DataType, ObjectType>* newField = 
@@ -663,7 +661,7 @@ namespace CamelotFramework
 		template<class ObjectType, class DataType>
 		void addReflectablePtrField(const String& name, UINT32 uniqueId, boost::any getter, boost::any setter, UINT64 flags)
 		{
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
+			static_assert((std::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
 				"Invalid data type for complex field. It needs to derive from CamelotFramework::IReflectable.");
 
 			if((flags & RTTI_Flag_WeakRef) == 0)
@@ -689,7 +687,7 @@ namespace CamelotFramework
 		void addReflectableArrayField(const String& name, UINT32 uniqueId, boost::any getter, boost::any getSize, 
 			boost::any setter, boost::any setSize, UINT64 flags)
 		{
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
+			static_assert((std::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
 				"Invalid data type for complex field. It needs to derive from CamelotFramework::IReflectable.");
 
 			RTTIReflectableField<DataType, ObjectType>* newField = 
@@ -702,7 +700,7 @@ namespace CamelotFramework
 		void addReflectablePtrArrayField(const String& name, UINT32 uniqueId, boost::any getter, boost::any getSize, 
 			boost::any setter, boost::any setSize, UINT64 flags)
 		{
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
+			static_assert((std::is_base_of<CamelotFramework::IReflectable, DataType>::value), 
 				"Invalid data type for complex field. It needs to derive from CamelotFramework::IReflectable.");
 
 			if((flags & RTTI_Flag_WeakRef) == 0)
@@ -733,7 +731,7 @@ namespace CamelotFramework
 	template<class T>
 	bool rtti_is_of_type(IReflectable* object)
 	{
-		BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::IReflectable, T>::value), 
+		static_assert((std::is_base_of<CamelotFramework::IReflectable, T>::value), 
 			"Invalid data type for type checking. It needs to derive from CamelotFramework::IReflectable.");
 
 		return object->getTypeId() == T::getRTTIStatic()->getRTTIId();
@@ -745,7 +743,7 @@ namespace CamelotFramework
 	template<class T>
 	bool rtti_is_of_type(std::shared_ptr<IReflectable> object)
 	{
-		BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::IReflectable, T>::value), 
+		static_assert((std::is_base_of<CamelotFramework::IReflectable, T>::value), 
 			"Invalid data type for type checking. It needs to derive from CamelotFramework::IReflectable.");
 
 		return object->getTypeId() == T::getRTTIStatic()->getRTTIId();