Packets: Fix VariantParser invalid parser access bug
[senf.git] / Utils / mpl.hh
index ba60083..fb1b566 100644 (file)
@@ -1,8 +1,8 @@
 // $Id$
 //
-// Copyright (C) 2007 
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Copyright (C) 2007
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
 //     Stefan Bund <g0dil@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
@@ -23,8 +23,8 @@
 /** \file
     \brief mpl public header */
 
-#ifndef HH_mpl_
-#define HH_mpl_ 1
+#ifndef HH_SENF_Utils_mpl_
+#define HH_SENF_Utils_mpl_ 1
 
 // Custom includes
 #include "../config.hh"
 namespace senf {
 namespace mpl {
 
-    /** \defgroup senfmpl Low-level template meta programming helpers
+    /** \defgroup senfmpl Template meta programming helpers
      */
 
+    /** \brief Marker class for empty default values etc.
+
+        This is like Boosts \c boost::mpl::na just an empty class used as template default argument
+        to mark missing arguments 
+        
+        \note Don't use this as an empty base class. We may add some informative members to this.
+        \ingroup senfmpl
+     */
+    struct nil {};
+
     /** \brief Return-value type used to implement overload selection
 
         The senf::mpl::rv type is used together with \ref SENF_MPL_RV() to select template
@@ -96,8 +106,8 @@ namespace mpl {
         never called.
 
         This number is than forwarded as template argument to \c select which is specialized for
-        each case. Therefore, <tt>choice<A></tt> has a \c frobble() member whereas
-        <tt>choice<B></tt> has a \c dazzle() member.
+        each case. Therefore, <tt>choice\<A\></tt> has a \c frobble() member whereas
+        <tt>choice\<B\></tt> has a \c dazzle() member.
 
         \see \ref SENF_MPL_RV
         \ingroup senfmpl
@@ -146,6 +156,8 @@ namespace mpl {
      */
     template <class _> struct take_class {};
 
+#ifndef SENF_MPL_SLOT_NOEXPAND
+
     /** \brief Define MPL slot
 
         The slot macros \ref SENF_MPL_SLOT_DEF(), \ref SENF_MPL_SLOT_SET() and \ref
@@ -182,6 +194,17 @@ namespace mpl {
         static senf::mpl::rv<0> _SENF_MPL_SLOT_ ## name (_);                                      \
         SENF_MPL_SLOT_SET(name,value)
 
+    /** \brief Define MPL slot initialized to 0
+
+        This is like \ref SENF_MPL_SLOT_DEF() but initializes the slot to the fixed value 0. The
+        advantage over \ref SENF_MPL_SLOT_DEF() is, that this macro may be called from an include
+        file whereas all the other \\c SENF_MPL_SLOT_ macros must always be called from the relevant
+        file.
+     */
+#   define SENF_MPL_SLOT_DEF_ZERO(name)                                                           \
+        template <class _>                                                                        \
+        static senf::mpl::rv<0> _SENF_MPL_SLOT_ ## name (_);
+
     /** \brief Set MPL slot
         \see \ref SENF_MPL_SLOT_DEF()
         \ingroup senfmpl
@@ -199,6 +222,8 @@ namespace mpl {
 #   define SENF_MPL_SLOT_GET(name)                                                                \
         SENF_MPL_SLOT_I_GET(name)
 
+#endif
+
 }}
 
 ///////////////////////////////hh.e////////////////////////////////////////