[Orxonox-commit 5806] r10466 - in code/branches/core7/src/libraries/core: class object
landauf at orxonox.net
landauf at orxonox.net
Mon May 25 11:33:05 CEST 2015
Author: landauf
Date: 2015-05-25 11:33:05 +0200 (Mon, 25 May 2015)
New Revision: 10466
Modified:
code/branches/core7/src/libraries/core/class/Identifier.h
code/branches/core7/src/libraries/core/object/IteratorBase.h
code/branches/core7/src/libraries/core/object/ObjectList.h
Log:
added static assertions to validate the type of certain templates
Modified: code/branches/core7/src/libraries/core/class/Identifier.h
===================================================================
--- code/branches/core7/src/libraries/core/class/Identifier.h 2015-05-25 08:24:56 UTC (rev 10465)
+++ code/branches/core7/src/libraries/core/class/Identifier.h 2015-05-25 09:33:05 UTC (rev 10466)
@@ -79,6 +79,8 @@
#include <string>
#include <typeinfo>
#include <loki/TypeTraits.h>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
#include "util/Output.h"
#include "util/OrxAssert.h"
@@ -256,6 +258,8 @@
template <class T>
class ClassIdentifier : public Identifier
{
+ BOOST_STATIC_ASSERT(boost::is_base_of<Identifiable, T>::value);
+
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define SUPER_INTRUSIVE_DECLARATION_INCLUDE
#include "Super.h"
Modified: code/branches/core7/src/libraries/core/object/IteratorBase.h
===================================================================
--- code/branches/core7/src/libraries/core/object/IteratorBase.h 2015-05-25 08:24:56 UTC (rev 10465)
+++ code/branches/core7/src/libraries/core/object/IteratorBase.h 2015-05-25 09:33:05 UTC (rev 10466)
@@ -37,6 +37,9 @@
#include "core/CorePrereqs.h"
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+
#include "ObjectListBase.h"
namespace orxonox
@@ -48,6 +51,8 @@
template <class T, class I>
class IteratorBase : public ObjectListElementRemovalListener
{
+ BOOST_STATIC_ASSERT(boost::is_base_of<Listable, T>::value);
+
public:
/**
@brief Constructor: Sets the element, whereon the iterator points, to zero.
Modified: code/branches/core7/src/libraries/core/object/ObjectList.h
===================================================================
--- code/branches/core7/src/libraries/core/object/ObjectList.h 2015-05-25 08:24:56 UTC (rev 10465)
+++ code/branches/core7/src/libraries/core/object/ObjectList.h 2015-05-25 09:33:05 UTC (rev 10466)
@@ -46,6 +46,9 @@
#include "core/CorePrereqs.h"
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+
#include "ObjectListBase.h"
#include "ObjectListIterator.h"
#include "Context.h"
@@ -65,6 +68,8 @@
template <class T>
class ObjectList
{
+ BOOST_STATIC_ASSERT(boost::is_base_of<Listable, T>::value);
+
public:
typedef ObjectListIterator<T> iterator;
More information about the Orxonox-commit
mailing list