In common.h, define func_lib for function objects. In configure.ac, define HAVE_STD_FUNCTION and HAVE_BOOST_FUNCTION. Include function headers in ndnboost.
diff --git a/ndnboost/functional/overloaded_function/config.hpp b/ndnboost/functional/overloaded_function/config.hpp
new file mode 100644
index 0000000..33ff1b5
--- /dev/null
+++ b/ndnboost/functional/overloaded_function/config.hpp
@@ -0,0 +1,50 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/functional/overloaded_function
+
+#ifndef BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_HPP_
+#define BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_HPP_
+
+/** @file
+@brief Change the compile-time configuration of this library.
+*/
+
+/**
+@brief Specify the maximum number of arguments of the functions being
+overloaded.
+
+If this macro is left undefined by the user, it has a default value of 5
+(increasing this number might increase compilation time).
+When specified by the user, this macro must be a non-negative integer number.
+
+@See @RefSect{getting_started, Getting Started},
+@RefClass{ndnboost::overloaded_function}.
+*/
+#ifndef BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX
+# define BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX 5
+#endif
+
+/**
+@brief Specify the maximum number of functions that can be overloaded.
+
+If this macro is left undefined by the user, it has a default value of 5
+(increasing this number might increase compilation time).
+When defined by the user, this macro must be an integer number greater or
+equal than 2 (because at least two distinct functions need to be specified in
+order to define an overload).
+
+@See @RefSect{getting_started, Getting Started},
+@RefClass{ndnboost::overloaded_function}.
+*/
+#ifndef BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX
+# define BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX 5
+#endif
+#if BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX < 2
+# error "maximum overload macro cannot be less than 2"
+#endif
+
+#endif // #include guard
+
diff --git a/ndnboost/functional/overloaded_function/detail/base.hpp b/ndnboost/functional/overloaded_function/detail/base.hpp
new file mode 100644
index 0000000..c4cef04
--- /dev/null
+++ b/ndnboost/functional/overloaded_function/detail/base.hpp
@@ -0,0 +1,86 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/functional/overloaded_function
+
+#if !BOOST_PP_IS_ITERATING
+# ifndef BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_DETAIL_BASE_HPP_
+# define BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_DETAIL_BASE_HPP_
+
+# include <ndnboost/functional/overloaded_function/config.hpp>
+# include <ndnboost/function.hpp>
+# include <ndnboost/preprocessor/iteration/iterate.hpp>
+# include <ndnboost/preprocessor/repetition/enum.hpp>
+# include <ndnboost/preprocessor/cat.hpp>
+# include <ndnboost/preprocessor/comma_if.hpp>
+
+#define BOOST_FUNCTIONAL_DETAIL_arg_type(z, n, unused) \
+ BOOST_PP_CAT(A, n)
+
+#define BOOST_FUNCTIONAL_DETAIL_arg_name(z, n, unused) \
+ BOOST_PP_CAT(a, n)
+
+#define BOOST_FUNCTIONAL_DETAIL_arg_tparam(z, n, unused) \
+ typename BOOST_FUNCTIONAL_DETAIL_arg_type(z, n, unused)
+
+#define BOOST_FUNCTIONAL_DETAIL_arg(z, n, unused) \
+ BOOST_FUNCTIONAL_DETAIL_arg_type(z, n, unused) \
+ BOOST_FUNCTIONAL_DETAIL_arg_name(z, n, unused)
+
+#define BOOST_FUNCTIONAL_DETAIL_f \
+ R (BOOST_PP_ENUM(BOOST_FUNCTIONAL_DETAIL_arity, \
+ BOOST_FUNCTIONAL_DETAIL_arg_type, ~))
+
+// Do not use namespace ::detail because overloaded_function is already a class.
+namespace ndnboost { namespace overloaded_function_detail {
+
+template<typename F>
+class base {}; // Empty template cannot be used directly (only its spec).
+
+# define BOOST_PP_ITERATION_PARAMS_1 \
+ (3, (0, BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX, \
+ "ndnboost/functional/overloaded_function/detail/base.hpp"))
+# include BOOST_PP_ITERATE() // Iterate over funciton arity.
+
+} } // namespace
+
+#undef BOOST_FUNCTIONAL_DETAIL_arg_type
+#undef BOOST_FUNCTIONAL_DETAIL_arg_name
+#undef BOOST_FUNCTIONAL_DETAIL_arg_tparam
+#undef BOOST_FUNCTIONAL_DETAIL_arg
+#undef BOOST_FUNCTIONAL_DETAIL_f
+
+# endif // #include guard
+
+#elif BOOST_PP_ITERATION_DEPTH() == 1
+# define BOOST_FUNCTIONAL_DETAIL_arity BOOST_PP_FRAME_ITERATION(1)
+
+template<
+ typename R
+ BOOST_PP_COMMA_IF(BOOST_FUNCTIONAL_DETAIL_arity)
+ BOOST_PP_ENUM(BOOST_FUNCTIONAL_DETAIL_arity,
+ BOOST_FUNCTIONAL_DETAIL_arg_tparam, ~)
+>
+class base< BOOST_FUNCTIONAL_DETAIL_f > {
+public:
+ /* implicit */ inline base(
+ // This requires specified type to be implicitly convertible to
+ // a ndnboost::function<> functor.
+ ndnboost::function< BOOST_FUNCTIONAL_DETAIL_f > const& f): f_(f)
+ {}
+
+ inline R operator()(BOOST_PP_ENUM(BOOST_FUNCTIONAL_DETAIL_arity,
+ BOOST_FUNCTIONAL_DETAIL_arg, ~)) const {
+ return f_(BOOST_PP_ENUM(BOOST_FUNCTIONAL_DETAIL_arity,
+ BOOST_FUNCTIONAL_DETAIL_arg_name, ~));
+ }
+
+private:
+ ndnboost::function< BOOST_FUNCTIONAL_DETAIL_f > const f_;
+};
+
+# undef BOOST_FUNCTIONAL_DETAIL_arity
+#endif // iteration
+
diff --git a/ndnboost/functional/overloaded_function/detail/function_type.hpp b/ndnboost/functional/overloaded_function/detail/function_type.hpp
new file mode 100644
index 0000000..7119f93
--- /dev/null
+++ b/ndnboost/functional/overloaded_function/detail/function_type.hpp
@@ -0,0 +1,85 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/functional/overloaded_function
+
+#ifndef BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_DETAIL_FUNCTION_TYPE_HPP_
+#define BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_DETAIL_FUNCTION_TYPE_HPP_
+
+#include <ndnboost/function_types/is_function.hpp>
+#include <ndnboost/function_types/is_function_pointer.hpp>
+#include <ndnboost/function_types/is_function_reference.hpp>
+#include <ndnboost/function_types/function_type.hpp>
+#include <ndnboost/function_types/parameter_types.hpp>
+#include <ndnboost/function_types/result_type.hpp>
+#include <ndnboost/type_traits/remove_pointer.hpp>
+#include <ndnboost/type_traits/remove_reference.hpp>
+#include <ndnboost/function.hpp>
+#include <ndnboost/mpl/if.hpp>
+#include <ndnboost/mpl/identity.hpp>
+#include <ndnboost/mpl/pop_front.hpp>
+#include <ndnboost/mpl/push_front.hpp>
+#include <ndnboost/typeof/typeof.hpp>
+
+// Do not use namespace ::detail because overloaded_function is already a class.
+namespace ndnboost { namespace overloaded_function_detail {
+
+// Requires: F is a monomorphic functor (i.e., has non-template `operator()`).
+// Returns: F's function type `result_type (arg1_type, arg2_type, ...)`.
+// It does not assume F typedef result_type, arg1_type, ... but needs typeof.
+template<typename F>
+class functor_type {
+ // NOTE: clang does not accept extra parenthesis `&(...)`.
+ typedef BOOST_TYPEOF_TPL(&F::operator()) call_ptr;
+public:
+ typedef
+ typename ndnboost::function_types::function_type<
+ typename ndnboost::mpl::push_front<
+ typename ndnboost::mpl::pop_front< // Remove functor type (1st).
+ typename ndnboost::function_types::parameter_types<
+ call_ptr>::type
+ >::type
+ , typename ndnboost::function_types::result_type<call_ptr>::type
+ >::type
+ >::type
+ type;
+};
+
+// NOTE: When using ndnboost::function in Boost.Typeof emulation mode, the user
+// has to register ndnboost::functionN instead of ndnboost::function in oder to
+// do TYPEOF(F::operator()). That is confusing, so ndnboost::function is handled
+// separately so it does not require any Boost.Typeof registration at all.
+template<typename F>
+struct functor_type< ndnboost::function<F> > {
+ typedef F type;
+};
+
+// Requires: F is a function type, pointer, reference, or monomorphic functor.
+// Returns: F's function type `result_type (arg1_type, arg2_type, ...)`.
+template<typename F>
+struct function_type {
+ typedef
+ typename ndnboost::mpl::if_<ndnboost::function_types::is_function<F>,
+ ndnboost::mpl::identity<F>
+ ,
+ typename ndnboost::mpl::if_<ndnboost::function_types::
+ is_function_pointer<F>,
+ ndnboost::remove_pointer<F>
+ ,
+ typename ndnboost::mpl::if_<ndnboost::function_types::
+ is_function_reference<F>,
+ ndnboost::remove_reference<F>
+ , // Else, requires that F is a functor.
+ functor_type<F>
+ >::type
+ >::type
+ >::type
+ ::type type;
+};
+
+} } // namespace
+
+#endif // #include guard
+