From: g0dil Date: Tue, 4 Nov 2008 13:23:04 +0000 (+0000) Subject: Packets: Add ComplexAnnotation check for current (4.3) g++ Versions using boost:... X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=3593676775cfadb0094eb4f472c6ced0763e0068;p=senf.git Packets: Add ComplexAnnotation check for current (4.3) g++ Versions using boost::is_pod git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@944 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Packets/Packet.test.cc b/Packets/Packet.test.cc index 8c28f73..dd8d173 100644 --- a/Packets/Packet.test.cc +++ b/Packets/Packet.test.cc @@ -28,6 +28,7 @@ // Custom includes #include +#include #include "Packets.hh" #include "../Utils/auto_unit_test.hh" @@ -126,6 +127,11 @@ namespace { struct ComplexEmptyAnnotation : senf::ComplexAnnotation {}; + struct InvalidAnnotation + { + std::string value; + }; + } BOOST_AUTO_UNIT_TEST(packet) @@ -273,6 +279,24 @@ BOOST_AUTO_UNIT_TEST(packetAnnotation) BOOST_CHECK( ! senf::detail::AnnotationIndexer::Small ); } +#ifdef COMPILE_CHECK + +COMPILE_FAIL(invalidAnnotation) +{ +# ifdef BOOST_HAS_TYPE_TRAITS_INTRINSICS + + senf::Packet packet (FooPacket::create()); + (void) packet.annotation(); + +# else + + BOOST_STATIC_ASSERT(( false )); + +# endif +} + +#endif + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ diff --git a/Packets/PacketImpl.hh b/Packets/PacketImpl.hh index 4aa2d8c..4b13fdd 100644 --- a/Packets/PacketImpl.hh +++ b/Packets/PacketImpl.hh @@ -31,6 +31,7 @@ #include #include #include +#include #include "../Utils/pool_alloc_mixin.hh" #include "PacketTypes.hh" #include "../Utils/singleton.hh" @@ -91,8 +92,14 @@ namespace detail { AnnotationIndexer(); unsigned index_; static unsigned index(); - static bool const Small = (sizeof(Annotation) <= sizeof(AnnotationEntry) - && ! boost::is_base_of::value); + static bool const Complex = boost::is_base_of::value; + static bool const Small = (sizeof(Annotation) <= sizeof(AnnotationEntry) && ! Complex); + +# ifdef BOOST_HAS_TYPE_TRAITS_INTRINSICS + + BOOST_STATIC_ASSERT(( boost::is_pod::value || Complex )); + +# endif }; template ::Small>