Packets: Add descriptive dump() output to DataPacket
[senf.git] / Packets / PacketImpl.hh
index 4aa2d8c..667eebb 100644 (file)
@@ -31,6 +31,9 @@
 #include <vector>
 #include <boost/utility.hpp>
 #include <boost/type_traits/is_base_of.hpp>
+#include <boost/type_traits/has_trivial_constructor.hpp>
+#include <boost/type_traits/has_trivial_destructor.hpp>
+#include <boost/static_assert.hpp>
 #include "../Utils/pool_alloc_mixin.hh"
 #include "PacketTypes.hh"
 #include "../Utils/singleton.hh"
@@ -91,8 +94,16 @@ namespace detail {
         AnnotationIndexer();
         unsigned index_;
         static unsigned index();
-        static bool const Small = (sizeof(Annotation) <= sizeof(AnnotationEntry) 
-                                   && ! boost::is_base_of<ComplexAnnotation, Annotation>::value);
+        static bool const Complex = boost::is_base_of<ComplexAnnotation, Annotation>::value;
+        static bool const Small = (sizeof(Annotation) <= sizeof(AnnotationEntry) && ! Complex);
+
+#       ifdef BOOST_HAS_TYPE_TRAITS_INTRINSICS
+
+        BOOST_STATIC_ASSERT(( (boost::has_trivial_constructor<Annotation>::value 
+                               && boost::has_trivial_destructor<Annotation>::value)
+                              || Complex ));
+
+#       endif
     };
 
     template <class Annotation, bool Small = AnnotationIndexer<Annotation>::Small>