THRIFT-1316. cpp: update server classes to accept
TProcessorFactory objects
Patch: Adam Simpkins
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1164201 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/Thrift.h b/lib/cpp/src/Thrift.h
index c6b31a8..df52dab 100644
--- a/lib/cpp/src/Thrift.h
+++ b/lib/cpp/src/Thrift.h
@@ -39,8 +39,33 @@
#include <exception>
#include <typeinfo>
+#include <boost/utility/enable_if.hpp>
+#include <boost/type_traits/is_convertible.hpp>
+
#include "TLogging.h"
+/**
+ * Helper macros to allow function overloading even when using
+ * boost::shared_ptr.
+ *
+ * shared_ptr makes overloading really annoying, since shared_ptr defines
+ * constructor methods to allow one shared_ptr type to be constructed from any
+ * other shared_ptr type. (Even if it would be a compile error to actually try
+ * to instantiate the constructor.) These macros add an extra argument to the
+ * function to cause it to only be instantiated if a pointer of type T is
+ * convertible to a pointer of type U.
+ *
+ * THRIFT_OVERLOAD_IF should be used in function declarations.
+ * THRIFT_OVERLOAD_IF_DEFN should be used in the function definition, if it is
+ * defined separately from where it is declared.
+ */
+#define THRIFT_OVERLOAD_IF_DEFN(T, Y) \
+ typename ::boost::enable_if<typename ::boost::is_convertible<T*, Y*>::type, \
+ void*>::type
+
+#define THRIFT_OVERLOAD_IF(T, Y) \
+ THRIFT_OVERLOAD_IF_DEFN(T, Y) = NULL
+
namespace apache { namespace thrift {
class TEnumIterator : public std::iterator<std::forward_iterator_tag, std::pair<int, const char*> > {