Boost logo

Boost-Commit :

From: mikhailberis_at_[hidden]
Date: 2007-11-01 11:42:26


Author: mikhailberis
Date: 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
New Revision: 40641
URL: http://svn.boost.org/trac/boost/changeset/40641

Log:
Initial import of overload implementation -- from Marco Ceccheti's 0.3.0 release, with minor modifications for 'boostification'.
Added:
   sandbox/overload/
   sandbox/overload/trunk/
   sandbox/overload/trunk/boost/
   sandbox/overload/trunk/boost/overload/
   sandbox/overload/trunk/boost/overload.hpp (contents, props changed)
   sandbox/overload/trunk/boost/overload/detail/
   sandbox/overload/trunk/boost/overload/detail/final_overload_base.hpp (contents, props changed)
   sandbox/overload/trunk/boost/overload/detail/function_trait.hpp (contents, props changed)
   sandbox/overload/trunk/boost/overload/detail/functor_has_signature.hpp (contents, props changed)
   sandbox/overload/trunk/boost/overload/detail/get_function_tag.hpp (contents, props changed)
   sandbox/overload/trunk/boost/overload/detail/if_metafunction.hpp (contents, props changed)
   sandbox/overload/trunk/boost/overload/detail/macro_def.hpp (contents, props changed)
   sandbox/overload/trunk/boost/overload/detail/macro_undef.hpp (contents, props changed)
   sandbox/overload/trunk/boost/overload/detail/member_function_form.hpp (contents, props changed)
   sandbox/overload/trunk/boost/overload/detail/member_function_trait.hpp (contents, props changed)
   sandbox/overload/trunk/boost/overload/detail/overload_base.hpp (contents, props changed)
   sandbox/overload/trunk/boost/overload/detail/trait_by_functor.hpp (contents, props changed)
   sandbox/overload/trunk/boost/overload/detail/trait_by_index.hpp (contents, props changed)
   sandbox/overload/trunk/boost/overload/detail/trait_by_signature.hpp (contents, props changed)
   sandbox/overload/trunk/boost/overload/overload_impl.hpp (contents, props changed)
   sandbox/overload/trunk/libs/
   sandbox/overload/trunk/libs/overload/
   sandbox/overload/trunk/libs/overload/docs/
   sandbox/overload/trunk/libs/overload/docs/README_FIRST.txt (contents, props changed)
   sandbox/overload/trunk/libs/overload/examples/
   sandbox/overload/trunk/libs/overload/examples/example_1.cpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/examples/example_2.cpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/examples/example_3.cpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/examples/example_4.cpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/examples/example_5.cpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/examples/example_6.cpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/examples/example_7a.cpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/examples/example_7b.cpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/examples/example_8a.cpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/examples/example_8b.cpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/tests/
   sandbox/overload/trunk/libs/overload/tests/Jamfile.v2 (contents, props changed)
   sandbox/overload/trunk/libs/overload/tests/test/
   sandbox/overload/trunk/libs/overload/tests/test.cpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/tests/test/free_and_member_functions.hpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/tests/test/functors.hpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/tests/test/idx_and_sig_methods.hpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/tests/test/signature_deduction.hpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/tests/test/signature_with_ptr_ref.hpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/tests/test/trait_by_functor.hpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/tests/test/trait_by_index.hpp (contents, props changed)
   sandbox/overload/trunk/libs/overload/tests/test/trait_by_signature.hpp (contents, props changed)

Added: sandbox/overload/trunk/boost/overload.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/boost/overload.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,29 @@
+/*=============================================================================
+ Copyright (c) 2007 Marco Cecchetti
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#ifndef _BOOST_OVERLOAD_HPP_
+#define _BOOST_OVERLOAD_HPP_
+
+
+#ifndef BOOST_OVERLOAD_LIMIT
+ #define BOOST_OVERLOAD_LIMIT 10
+#endif
+
+#define BOOST_OVERLOAD_MAX_NUM_ARGS 10
+
+//#define BOOST_MSVC 1310 // for test only
+
+#include <boost/detail/workaround.hpp>
+
+#include "overload/detail/macro_def.hpp"
+#include "overload/overload_impl.hpp"
+#include "overload/detail/macro_undef.hpp"
+
+
+#endif // _BOOST_OVERLOAD_HPP_
+

Added: sandbox/overload/trunk/boost/overload/detail/final_overload_base.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/boost/overload/detail/final_overload_base.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,35 @@
+/*=============================================================================
+ Copyright (c) 2007 Marco Cecchetti
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#ifndef _BOOST_DETAIL_FINAL_OVERLOAD_BASE_HPP_
+#define _BOOST_DETAIL_FINAL_OVERLOAD_BASE_HPP_
+
+//#include <limits>
+#include <boost/function.hpp>
+
+namespace boost{ namespace overloads{ namespace detail{
+
+///////////////////////////////////////////////////////////////////////////////
+// stop recursion structs
+
+struct no_signature {};
+
+struct final_overload_base
+{
+ static const unsigned int index = UINT_MAX;
+ typedef final_overload_base base_type;
+ typedef boost::function<no_signature> function_type;
+ typedef no_signature signature_type;
+ struct final;
+ void operator()(final*) const {}
+};
+
+} } } // end namespaces
+
+#endif // _BOOST_DETAIL_FINAL_OVERLOAD_BASE_HPP_
+

Added: sandbox/overload/trunk/boost/overload/detail/function_trait.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/boost/overload/detail/function_trait.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,154 @@
+/*=============================================================================
+ Copyright (c) 2007 Marco Cecchetti
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#ifndef _FUNCTION_TRAIT_HPP_
+#define _FUNCTION_TRAIT_HPP_
+
+
+///////////////////////////////////////////////////////////////////////////////
+// this file contains type trait metafunctions used for making up a
+// workaround implementation for MSVC < 8.0 (tested on MSVC 7.1 )
+
+#include <boost/type_traits/function_traits.hpp>
+
+#include "final_overload_base.hpp"
+#include "if_metafunction.hpp"
+
+///////////////////////////////////////////////////////////////////////////////
+// helper macros
+
+#define OVL_ARG_TYPE(z, n, type) \
+typedef type BOOST_PP_CAT(arg, BOOST_PP_CAT(n, _type));
+// end macro OVL_ARG_TYPE
+
+#define OVL_IS_SIG_ARITY_ZERO(z, n, sig) \
+( func_trait<BOOST_PP_CAT(sig,n)>::arity == 0 ) ||
+// end macro OVL_IS_SIG_ARITY_ZERO
+
+
+namespace boost{ namespace overloads{ namespace detail{
+
+struct no_type;
+
+template<unsigned int N>
+struct dummy_signature;
+
+// every signature has to have its dummy type
+template<unsigned int N>
+struct dummy_type;
+
+template< typename error_type>
+struct error{};
+
+// used as error message
+struct no_function_found_matching_function_call;
+struct ambiguous_function_call;
+
+///////////////////////////////////////////////////////////////////////////////
+// func_trait is used to create some function traits specialization that
+// provides dummy argument types and compile time errors pointing out the real
+// compile issues
+
+template< typename Signature >
+struct func_trait : public boost::function_traits<Signature>
+{
+};
+
+template<>
+struct func_trait< no_signature >
+{
+ static const unsigned int arity = UINT_MAX;
+ typedef no_type result_type;
+ BOOST_PP_REPEAT_FROM_TO(1, BOOST_OVERLOAD_MAX_NUM_ARGS, OVL_ARG_TYPE, no_type);
+};
+
+template<unsigned int N>
+struct func_trait< dummy_signature<N> >
+{
+ static const unsigned int arity = UINT_MAX;
+ typedef dummy_type<N> result_type;
+ BOOST_PP_REPEAT_FROM_TO(1, BOOST_OVERLOAD_MAX_NUM_ARGS, OVL_ARG_TYPE, dummy_type<N>);
+};
+
+template<typename error_type>
+struct func_trait< error<error_type> >
+{
+ static const unsigned int arity = UINT_MAX;
+ typedef error_type result_type;
+ BOOST_PP_REPEAT_FROM_TO(1, BOOST_OVERLOAD_MAX_NUM_ARGS, OVL_ARG_TYPE, error_type);
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
+// metafunction zero_arity_signature
+// if one and only one of the signature has zero arity type is defined as such
+// a signature; if there is no signature with zero arity type is defined as
+// no_function_found_matching_function_call; if the is more than one signature
+// with zero arity type is defined as ambiguous_function_call
+
+// only an helper metafunction
+template<bool cond, typename S>
+struct if_not_ambiguous
+{
+ typedef
+ typename if_c<cond, S, error<ambiguous_function_call> >::type
+ type;
+};
+
+template< BOOST_PP_ENUM_PARAMS(BOOST_OVERLOAD_LIMIT, typename Sig) >
+struct zero_arity_signature
+{
+ private:
+ static const bool sig0_no_arg = ( func_trait<Sig0>::arity == 0 );
+ static const bool sig0_no_other_no_arg
+ = !( BOOST_PP_REPEAT_FROM_TO(1, BOOST_OVERLOAD_LIMIT,
+ OVL_IS_SIG_ARITY_ZERO, Sig) false );
+ public:
+ typedef
+ typename if_c<sig0_no_arg,
+ typename if_not_ambiguous<sig0_no_other_no_arg, Sig0>::type,
+ typename zero_arity_signature<
+ BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_OVERLOAD_LIMIT, Sig), no_signature
+ >::type
+ >::type
+ type;
+};
+
+template< BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_OVERLOAD_LIMIT, typename Sig) >
+struct zero_arity_signature<
+ no_signature,
+ BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_OVERLOAD_LIMIT, Sig)
+>
+{
+ typedef error<no_function_found_matching_function_call> type;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// metafunction real_or_dummy_signature
+// if the signature arity is equal to arity type is defined as the passed
+// signature on the contrary type is defined as an ad-hoc dummy_signature<N>
+
+template<unsigned int N, typename S, unsigned int arity>
+struct real_or_dummy_signature
+{
+ private:
+ static const bool same_arity = ( func_trait<S>::arity == arity );
+ public:
+ typedef
+ typename if_c< same_arity, S, dummy_signature<N> >::type
+ type;
+};
+
+
+} } } // end namespaces
+
+#undef OVL_IS_SIG_ARITY_ZERO
+#undef OVL_ARG_TYPE
+
+#endif // _FUNCTION_TRAIT_HPP_
+

Added: sandbox/overload/trunk/boost/overload/detail/functor_has_signature.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/boost/overload/detail/functor_has_signature.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,128 @@
+/*=============================================================================
+ Copyright (c) 2007 Marco Cecchetti
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#ifndef _BOOST_OVERLOAD_DETAIL_FUNCTOR_HAS_SIGNATURE_HPP_
+#define _BOOST_OVERLOAD_DETAIL_FUNCTOR_HAS_SIGNATURE_HPP_
+
+
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/remove_pointer.hpp>
+
+#include "member_function_trait.hpp"
+#include "get_function_tag.hpp"
+
+namespace boost{ namespace overloads{ namespace detail{
+
+///////////////////////////////////////////////////////////////////////////////
+// utility to test if a function object has a specific signature
+
+struct member_func_non_const_tag {};
+
+template< typename FunctionObj, typename Sig,
+ typename const_tag = member_func_non_const_tag >
+struct func_obj_has_signature
+{
+ private:
+ typedef typename memb_func_trait<Sig FunctionObj::*>::type memb_func_ptr;
+ template<memb_func_ptr> struct helper;
+ template<typename T> static char check(helper<&T::operator()>* );
+ template<typename T> static char (& check(...))[2];
+ public:
+ static const bool value = ( sizeof(check<FunctionObj>(0)) == sizeof(char) );
+};
+
+template<typename FunctionObj>
+struct func_obj_has_signature<FunctionObj, no_signature, member_func_non_const_tag>
+{
+ static const bool value = false;
+};
+
+struct member_func_const_tag {}; // for member functions of kind "R f(..) const"
+
+template<typename FunctionObj, typename Sig >
+struct func_obj_has_signature<FunctionObj, Sig, member_func_const_tag>
+{
+ private:
+ typedef typename memb_func_trait<Sig FunctionObj::*>::const_type
+ memb_func_ptr;
+ template<memb_func_ptr> struct helper;
+ template<typename T> static char check(helper<&T::operator()>* );
+ template<typename T> static char (& check(...))[2];
+ public:
+ static const bool value = ( sizeof(check<FunctionObj>(0)) == sizeof(char) );
+};
+
+template<typename FunctionObj>
+struct func_obj_has_signature<FunctionObj, no_signature, member_func_const_tag>
+{
+ static const bool value = false;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// utility to test if a functor has a specific signature
+
+template< typename Functor,
+ typename Sig,
+ typename function_tag
+ = typename get_function_tag<Functor>::type
+>
+struct functor_has_signature{ static const bool value = false; };
+
+template< typename FunctionPtr, typename Sig>
+struct functor_has_signature<FunctionPtr, Sig, function_ptr_tag>
+{
+ private:
+ typedef typename remove_pointer<FunctionPtr>::type func_ptr_t;
+ public:
+ static const bool value = boost::is_same<func_ptr_t, Sig>::value;
+};
+
+template< typename MemberPtr, typename Sig>
+struct functor_has_signature<MemberPtr, Sig, member_ptr_tag>
+{
+ private:
+ typedef
+ typename memb_func_trait<MemberPtr>::binded_type
+ binded_type;
+ typedef
+ typename memb_func_trait<MemberPtr>::const_binded_type
+ const_binded_type;
+ static const bool const_qualified
+ = memb_func_trait<MemberPtr>::const_qualified;
+ public:
+ static const bool value
+ = boost::is_same<binded_type, Sig>::value
+ || (boost::is_same<const_binded_type, Sig>::value && const_qualified);
+};
+
+template< typename FunctionObj, typename Sig>
+struct functor_has_signature<FunctionObj, Sig, function_obj_tag>
+{
+ static const bool value
+ = func_obj_has_signature<FunctionObj, Sig>::value
+ || func_obj_has_signature<FunctionObj, Sig, member_func_const_tag>::value;
+};
+
+template< typename FunctionObj, typename Sig>
+struct functor_has_signature<boost::reference_wrapper<FunctionObj>, Sig, function_obj_ref_tag>
+{
+ static const bool value
+ = func_obj_has_signature<FunctionObj, Sig>::value
+ || func_obj_has_signature<FunctionObj, Sig, member_func_const_tag>::value;
+};
+
+template< typename FuncSig, typename Sig>
+struct functor_has_signature< boost::function<FuncSig>, Sig, function_obj_tag >
+{
+ static const bool value = boost::is_same<FuncSig, Sig>::value;
+};
+
+} } } // end namespaces
+
+#endif // _BOOST_OVERLOAD_DETAIL_FUNCTOR_HAS_SIGNATURE_HPP_
+

Added: sandbox/overload/trunk/boost/overload/detail/get_function_tag.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/boost/overload/detail/get_function_tag.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,62 @@
+/*=============================================================================
+ Copyright (c) 2007 Marco Cecchetti
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#ifndef _BOOST_OVERLOAD_DETAIL_GET_FUNCTION_TAG_HPP
+#define _BOOST_OVERLOAD_DETAIL_GET_FUNCTION_TAG_HPP
+
+
+#include <boost/type_traits/is_pointer.hpp>
+#include <boost/type_traits/is_member_pointer.hpp>
+#include <boost/ref.hpp>
+
+#include "if_metafunction.hpp"
+
+namespace boost{ namespace overloads{ namespace detail{
+
+///////////////////////////////////////////////////////////////////////////////
+// Tags used to decide between different types of functions
+// This implementation is based on Douglas Gregor's code
+// see boost/function/function_base.hpp, I bring some minor change in.
+
+struct function_ptr_tag {};
+struct function_obj_tag {};
+struct member_ptr_tag {};
+struct function_obj_ref_tag {};
+
+template<typename F>
+class get_function_tag
+{
+ typedef typename if_c<(boost::is_pointer<F>::value),
+ function_ptr_tag,
+ function_obj_tag>::type ptr_or_obj_tag;
+
+ typedef typename if_c<(boost::is_member_pointer<F>::value),
+ member_ptr_tag,
+ ptr_or_obj_tag>::type ptr_or_obj_or_mem_tag;
+
+ typedef typename if_c<(boost::is_reference_wrapper<F>::value),
+ function_obj_ref_tag,
+ ptr_or_obj_or_mem_tag>::type or_ref_tag;
+
+ public:
+ typedef or_ref_tag type;
+};
+
+
+template<typename F>
+struct is_ptr_or_memb_ptr
+{
+ static const bool value
+ = boost::is_pointer<F>::value
+ || boost::is_member_pointer<F>::value;
+};
+
+} } } // end namespaces
+
+#endif // _BOOST_OVERLOAD_DETAIL_GET_FUNCTION_TAG_HPP
+

Added: sandbox/overload/trunk/boost/overload/detail/if_metafunction.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/boost/overload/detail/if_metafunction.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,31 @@
+
+#ifndef _BOOST_OVERLOAD_DETAIL__IF_METAFUNCTION_HPP_
+#define _BOOST_OVERLOAD_DETAIL__IF_METAFUNCTION_HPP_
+
+
+namespace boost{ namespace overloads{ namespace detail{
+
+///////////////////////////////////////////////////////////////////////////////
+// if metafunction
+
+template< bool C, typename T, typename E >
+struct if_c
+{
+ typedef T type;
+};
+
+template<typename T, typename E >
+struct if_c<false, T, E>
+{
+ typedef E type;
+};
+
+template< typename C, typename T, typename E >
+struct if_ : if_c<C::value, T, E >
+{
+};
+
+} } } // end namespaces
+
+#endif // _BOOST_OVERLOAD_DETAIL__IF_METAFUNCTION_HPP_
+

Added: sandbox/overload/trunk/boost/overload/detail/macro_def.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/boost/overload/detail/macro_def.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,103 @@
+/*=============================================================================
+ Copyright (c) 2007 Marco Cecchetti
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#ifndef _BOOST_OVERLOAD_DETAIL_MACRO_DEF_HPP_
+#define _BOOST_OVERLOAD_DETAIL_MACRO_DEF_HPP_
+
+
+#include <boost/preprocessor/repetition.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/arithmetic/inc.hpp>
+
+
+#define OVL_DEFAULT_TEMPL_ARG(z, n, unused) \
+detail::no_signature
+// end macro OVL_DEFAULT_TEMPL_ARG
+
+#define OVL_TEMPL_PARAMS(z, n, T) \
+typename BOOST_PP_CAT(T, n) = OVL_DEFAULT_TEMPL_ARG(z, n, unused)
+// end macro OVL_TEMPL_PARAMS
+
+#define OVL_SET_IMPL(z, n, f) \
+set_impl( BOOST_PP_CAT(f, n) ); \
+
+// end macro OVL_ASSIGN_TO
+
+#define OVL_SET(z, n, unused) \
+template< BOOST_PP_ENUM_PARAMS(n, typename F) > \
+this_type& set( BOOST_PP_ENUM_BINARY_PARAMS(n, F, const& _f) ) \
+{ \
+ BOOST_PP_REPEAT(n, OVL_SET_IMPL, _f) \
+ return *this; \
+} \
+
+// end macro OVL_CTOR
+
+#define OVL_CTOR(z, n, unused) \
+template< BOOST_PP_ENUM_PARAMS(n, typename F) > \
+overload( BOOST_PP_ENUM_BINARY_PARAMS(n, F, const& _f) ) \
+{ \
+ set( BOOST_PP_ENUM_PARAMS(n, _f) ); \
+} \
+
+// end macro OVL_CTOR
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Workarounds for MSVC < 8.0 tested on MSVC 7.1
+
+#if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
+
+#define OVL_REAL_OR_DUMMY_SIG_M_N(z, m, n) \
+typedef \
+ typename detail::real_or_dummy_signature<n, BOOST_PP_CAT(Sig, n), m>::type \
+ BOOST_PP_CAT(sig_, BOOST_PP_CAT(n, BOOST_PP_CAT(_, BOOST_PP_CAT(m, _t)))); \
+
+//end macro OVL_REAL_OR_DUMMY_SIG_M_N
+
+#define OVL_REAL_OR_DUMMY_SIG_M(z, n, unused) \
+BOOST_PP_REPEAT(BOOST_OVERLOAD_MAX_NUM_ARGS, OVL_REAL_OR_DUMMY_SIG_M_N, n)
+// end macro OVL_REAL_OR_DUMMY_SIG_M
+
+#define OVL_FC_OP_PARAM(z, m, tuple) \
+typename detail::func_trait< \
+ BOOST_PP_CAT(sig_, \
+ BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, tuple), \
+ BOOST_PP_CAT(_, \
+ BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 1, tuple), _t) \
+ ) \
+ ) \
+ ) \
+>::BOOST_PP_CAT(arg, BOOST_PP_CAT(m, _type)) BOOST_PP_CAT(a, m) \
+
+// end macro OVL_FC_OP_PARAM
+
+#define OVL_FUNC_CALL_OPERATOR_M_N(z, m, n) \
+typename detail::func_trait<BOOST_PP_CAT(Sig,n)>::result_type \
+operator() ( BOOST_PP_ENUM_SHIFTED(BOOST_PP_INC(m), OVL_FC_OP_PARAM, (n, m)) ) \
+{ \
+ typedef \
+ BOOST_PP_CAT(sig_,BOOST_PP_CAT(n,BOOST_PP_CAT(_,BOOST_PP_CAT(m, _t)))) \
+ signature_type; \
+ return boost::function<signature_type>:: \
+ operator()( BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_INC(m), a) ); \
+} \
+
+// end macro OVL_FUNC_CALL_OPERATOR_M_N
+
+#define OVL_FUNC_CALL_OPERATORS(z, n, unused) \
+BOOST_PP_REPEAT_FROM_TO(1, BOOST_OVERLOAD_MAX_NUM_ARGS, OVL_FUNC_CALL_OPERATOR_M_N, n)
+// end macro OVL_FUNC_CALL_OPERATORS
+
+#endif
+// end workarounds for MSVC < 8.0 tested on MSVC 7.1
+///////////////////////////////////////////////////////////////////////////////
+
+
+#endif // _BOOST_OVERLOAD_DETAIL_MACRO_DEF_HPP_
+

Added: sandbox/overload/trunk/boost/overload/detail/macro_undef.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/boost/overload/detail/macro_undef.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,31 @@
+/*=============================================================================
+ Copyright (c) 2007 Marco Cecchetti
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+
+#ifndef _BOOST_DETAIL_OVERLOAD_MACRO_UNDEF_HPP_
+#define _BOOST_DETAIL_OVERLOAD_MACRO_UNDEF_HPP_
+
+
+// cleanup macro defs
+
+#undef OVL_CTOR
+#undef OVL_SET
+#undef OVL_SET_IMPL
+#undef OVL_TEMPL_PARAMS
+#undef OVL_DEFAULT_TEMPL_ARG
+
+// macro workarounds for MSVC < 8.0 tested on MSVC 7.1
+#undef OVL_FUNC_CALL_OPERATORS
+#undef OVL_FUNC_CALL_OPERATOR_M_N
+#undef OVL_FC_OP_PARAM
+#undef OVL_REAL_OR_DUMMY_SIG_M
+#undef OVL_REAL_OR_DUMMY_SIG_M_N
+
+
+#endif // _BOOST_DETAIL_OVERLOAD_MACRO_UNDEF_HPP_
+

Added: sandbox/overload/trunk/boost/overload/detail/member_function_form.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/boost/overload/detail/member_function_form.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,110 @@
+/*=============================================================================
+ Copyright (c) 2007 Marco Cecchetti
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#ifndef _BOOST_OVERLOAD_DETAIL_MEMBER_FUNCTION_FORM_HPP_
+#define _BOOST_OVERLOAD_DETAIL_MEMBER_FUNCTION_FORM_HPP_
+
+#include <boost/type_traits/function_traits.hpp>
+#include <boost/type_traits/remove_pointer.hpp>
+#include <boost/type_traits/is_pointer.hpp>
+#include <boost/type_traits/is_class.hpp>
+
+#include "member_function_trait.hpp"
+
+#define OVL_MEMB_FUNC_FORM(z, n, unused) \
+template< typename ClassT, \
+ typename R BOOST_PP_ENUM_TRAILING_PARAMS(n, typename A) > \
+struct memb_func_form< \
+ R ( ClassT* BOOST_PP_ENUM_TRAILING_PARAMS(n, A) ), non_const, true> \
+{ \
+ private: \
+ typedef memb_func_trait< R (ClassT::*) ( BOOST_PP_ENUM_PARAMS(n, A) ) > \
+ traits; \
+ public: \
+ typedef typename traits::type type; \
+}; \
+ \
+template< typename ClassT, \
+ typename R BOOST_PP_ENUM_TRAILING_PARAMS(n, typename A) > \
+struct memb_func_form< \
+ R ( ClassT* BOOST_PP_ENUM_TRAILING_PARAMS(n, A) ), const_, true> \
+{ \
+ private: \
+ typedef memb_func_trait< R (ClassT::*) ( BOOST_PP_ENUM_PARAMS(n, A) ) > \
+ traits; \
+ public: \
+ typedef typename traits::const_type type; \
+}; \
+ \
+template< typename ClassT, \
+ typename R BOOST_PP_ENUM_TRAILING_PARAMS(n, typename A) > \
+struct memb_func_form< \
+ R ( const ClassT* BOOST_PP_ENUM_TRAILING_PARAMS(n, A) ), const_, true > \
+{ \
+ private: \
+ typedef memb_func_trait< R (ClassT::*) ( BOOST_PP_ENUM_PARAMS(n, A) ) > \
+ traits; \
+ public: \
+ typedef typename traits::const_type type; \
+}; \
+ \
+template< typename ClassT, \
+ typename R BOOST_PP_ENUM_TRAILING_PARAMS(n, typename A) > \
+struct memb_func_form< \
+ R ( const ClassT* BOOST_PP_ENUM_TRAILING_PARAMS(n, A) ), non_const, true > \
+{ \
+}; \
+
+// end macro OVL_MEMB_FUNC_FORM
+
+namespace boost{ namespace overloads{ namespace detail{
+
+///////////////////////////////////////////////////////////////////////////////
+// return true if the first parameter type of the function is a pointer or
+// a const pointer to a class
+
+template< typename Signature,
+ unsigned int arity = boost::function_traits<Signature>::arity >
+struct is_interface_func
+{
+ private:
+ typedef typename boost::function_traits<Signature>::arg1_type arg_type;
+ typedef typename boost::remove_pointer<arg_type>::type candidate_type;
+ public:
+ static const bool value
+ = boost::is_class<candidate_type>::value
+ && boost::is_pointer<arg_type>::value;
+};
+
+template< typename Signature >
+struct is_interface_func<Signature, 0>
+{
+ static const bool value = false;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// provides the type pointer to function member whose signature and class
+// type owner are deduced from the signature of the equivalent free function
+
+struct const_;
+struct non_const;
+
+template< typename Signature,
+ typename const_qualifier = non_const,
+ bool enable = is_interface_func<Signature>::value >
+struct memb_func_form
+{};
+
+BOOST_PP_REPEAT(BOOST_OVERLOAD_LIMIT, OVL_MEMB_FUNC_FORM, unused)
+
+} } } // end namespaces
+
+#undef OVL_MEMB_FUNC_FORM
+
+#endif // _BOOST_OVERLOAD_DETAIL_MEMBER_FUNCTION_FORM_HPP_
+

Added: sandbox/overload/trunk/boost/overload/detail/member_function_trait.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/boost/overload/detail/member_function_trait.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,55 @@
+/*=============================================================================
+ Copyright (c) 2007 Marco Cecchetti
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#ifndef _BOOST_OVERLOAD_DETAIL_MEMBER_FUNCTION_TRAIT_HPP_
+#define _BOOST_OVERLOAD_DETAIL_MEMBER_FUNCTION_TRAIT_HPP_
+
+
+///////////////////////////////////////////////////////////////////////////////
+// member function traits
+
+#define OVL_MEMB_FUNC_TRAIT(z, n, unused) \
+template< typename ClassT, \
+ typename R BOOST_PP_ENUM_TRAILING_PARAMS(n, typename A) > \
+struct memb_func_trait< R (ClassT::*) ( BOOST_PP_ENUM_PARAMS(n, A) ) > \
+{ \
+ typedef ClassT class_type; \
+ typedef R sig_type( BOOST_PP_ENUM_PARAMS(n, A) ); \
+ typedef R (ClassT::* type) ( BOOST_PP_ENUM_PARAMS(n, A) ); \
+ typedef R (ClassT::* const_type) ( BOOST_PP_ENUM_PARAMS(n, A) ) const; \
+ typedef R binded_type( ClassT* BOOST_PP_ENUM_TRAILING_PARAMS(n, A) ); \
+ typedef \
+ R const_binded_type(const ClassT* BOOST_PP_ENUM_TRAILING_PARAMS(n,A) );\
+ static const bool const_qualified = false; \
+}; \
+ \
+template< typename ClassT, \
+ typename R BOOST_PP_ENUM_TRAILING_PARAMS(n, typename A) > \
+struct memb_func_trait< R (ClassT::*) ( BOOST_PP_ENUM_PARAMS(n, A) ) const > \
+ : memb_func_trait< R (ClassT::*) ( BOOST_PP_ENUM_PARAMS(n, A) ) > \
+{ \
+ static const bool const_qualified = true; \
+}; \
+
+// end macro OVL_MEMB_FUNC_TRAIT
+
+
+namespace boost{ namespace overloads{ namespace detail{
+
+template< typename MemberPtr>
+struct memb_func_trait
+{};
+
+BOOST_PP_REPEAT(BOOST_OVERLOAD_LIMIT, OVL_MEMB_FUNC_TRAIT, unused)
+
+} } } // end namespaces
+
+#undef OVL_MEMB_FUNC_TRAIT
+
+#endif // _BOOST_OVERLOAD_DETAIL_MEMBER_FUNCTION_TRAIT_HPP_
+

Added: sandbox/overload/trunk/boost/overload/detail/overload_base.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/boost/overload/detail/overload_base.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,66 @@
+/*=============================================================================
+ Copyright (c) 2007 Marco Cecchetti
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#ifndef _BOOST_DETAIL_OVERLOAD_BASE_HPP_
+#define _BOOST_DETAIL_OVERLOAD_BASE_HPP_
+
+#include <boost/function.hpp>
+
+#include "final_overload_base.hpp"
+
+namespace boost{ namespace overloads{ namespace detail{
+
+///////////////////////////////////////////////////////////////////////////////
+// overload_base class
+
+template<
+ unsigned int N,
+ typename Sig0,
+ BOOST_PP_ENUM_SHIFTED(BOOST_OVERLOAD_LIMIT, OVL_TEMPL_PARAMS, Sig)
+>
+struct overload_base
+ : public boost::function<Sig0>
+ , public overload_base<N+1, BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_OVERLOAD_LIMIT, Sig)>
+{
+ static const unsigned int index = N;
+
+ typedef Sig0 signature_type;
+ typedef boost::function<Sig0> function_type;
+ typedef
+ overload_base<N+1, BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_OVERLOAD_LIMIT, Sig)>
+ base_type;
+
+// Workaround for MSVC < 8.0 tested on MSVC 7.1
+#if !BOOST_WORKAROUND(BOOST_MSVC, < 1400)
+ using function_type::operator();
+ using base_type::operator();
+#endif
+};
+
+template< unsigned int N, typename Sig0 >
+struct overload_base<N, Sig0>
+ : public boost::function<Sig0>
+ , public final_overload_base
+{
+ static const unsigned int index = N;
+
+ typedef Sig0 signature_type;
+ typedef boost::function<Sig0> function_type;
+ typedef final_overload_base base_type;
+
+// Workaround for MSVC < 8.0 tested on MSVC 7.1
+#if !BOOST_WORKAROUND(BOOST_MSVC, < 1400)
+ using function_type::operator();
+#endif
+};
+
+} } } // end namespaces
+
+
+#endif // _BOOST_DETAIL_OVERLOAD_BASE_HPP_
+

Added: sandbox/overload/trunk/boost/overload/detail/trait_by_functor.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/boost/overload/detail/trait_by_functor.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,98 @@
+/*=============================================================================
+ Copyright (c) 2007 Marco Cecchetti
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#ifndef _BOOST_OVERLOAD_DETAIL_TRAIT_BY_FUNCTOR_HPP_
+#define _BOOST_OVERLOAD_DETAIL_TRAIT_BY_FUNCTOR_HPP_
+
+#include "final_overload_base.hpp"
+#include "functor_has_signature.hpp"
+
+namespace boost{ namespace overloads{ namespace detail{
+
+///////////////////////////////////////////////////////////////////////////////
+// it provides the base that inherits directly by boost::function<Sig> where Sig
+// is the first signature defined in Overload that matches the functor signature,
+// if it's not found returns final_overload_base as type
+
+template<
+ typename Functor,
+ typename Overload,
+ bool FOUND
+ = functor_has_signature<Functor, typename Overload::base_type::signature_type >::value
+>
+struct base_by_functor
+{
+ private:
+ typedef typename Overload::base_type base_type;
+ public:
+ typedef typename base_by_functor<Functor, base_type>::type type;
+};
+
+template< typename Functor, typename Overload >
+struct base_by_functor<Functor, Overload, true>
+{
+ typedef typename Overload::base_type type;
+};
+
+template< typename Functor, bool FOUND >
+struct base_by_functor<Functor, final_overload_base, FOUND>
+{
+ typedef final_overload_base type;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// it provides the first signature of an overload type that matches with
+// the functor signature, if it's not found it returns no_signature as type
+
+template< typename Functor, typename Overload>
+struct signature_by_functor
+{
+ typedef typename base_by_functor<Functor, Overload>::type::signature_type
+ type;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// it provides the type of the boost::function embedded object whose signature
+// matches with the functor signature, if it's not found it returns
+// boost::function<no_signature> as type;
+
+template< typename Functor, typename Overload >
+struct function_by_functor
+{
+ typedef
+ typename base_by_functor<Functor, Overload>::type::function_type
+ type;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// it provides the index of the first signature of an overload type that
+// matches with the functor signature, if it's not found it returns -1
+
+template< typename Functor, typename Overload >
+struct index_by_functor
+{
+ static const unsigned int value
+ = base_by_functor<Functor, Overload>::type::index;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// utility to discover if a given functor has a signature included in
+// an overload type
+
+template< typename Functor, typename Overload >
+struct has_functor_signature
+{
+ static const bool value
+ = !( index_by_functor<Functor, Overload>::value
+ == final_overload_base::index );
+};
+
+} } } // end namespaces
+
+#endif // _BOOST_OVERLOAD_DETAIL_TRAIT_BY_FUNCTOR_HPP_
+

Added: sandbox/overload/trunk/boost/overload/detail/trait_by_index.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/boost/overload/detail/trait_by_index.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,74 @@
+/*=============================================================================
+ Copyright (c) 2007 Marco Cecchetti
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#ifndef _BOOST_OVERLOAD_DETAIL_TRAIT_BY_INDEX_HPP_
+#define _BOOST_OVERLOAD_DETAIL_TRAIT_BY_INDEX_HPP_
+
+#include "final_overload_base.hpp"
+
+namespace boost{ namespace overloads{ namespace detail{
+
+///////////////////////////////////////////////////////////////////////////////
+// it provides the amount of signatures supported by the overload type
+
+template< typename Overload >
+struct extent
+{
+ private:
+ typedef typename Overload::base_type base;
+ public:
+ static const int value = extent<base>::value + 1;
+};
+
+template<>
+struct extent<final_overload_base>
+{
+ static const int value = final_overload_base::index;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// it provides the N-th base for an overload type
+
+
+template< unsigned int N, typename Overload,
+ bool FOUND = (N == Overload::base_type::index) >
+struct base_by_idx
+{
+ typedef typename base_by_idx<N, typename Overload::base_type>::type type;
+};
+
+template< unsigned int N, typename Overload >
+struct base_by_idx<N, Overload, true>
+{
+ typedef typename Overload::base_type type;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// it provides the N-th signature for an overload type
+
+template< unsigned int N, typename Overload>
+struct signature
+{
+ typedef typename base_by_idx<N, Overload>::type::signature_type type;
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
+// it provides the type of the N-th boost::function embedded object
+
+template< unsigned int N, typename Overload >
+struct function
+{
+ typedef typename base_by_idx<N, Overload>::type::function_type type;
+};
+
+} } } // end namespaces
+
+
+#endif // _BOOST_OVERLOAD_DETAIL_TRAIT_BY_INDEX_HPP_
+

Added: sandbox/overload/trunk/boost/overload/detail/trait_by_signature.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/boost/overload/detail/trait_by_signature.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,71 @@
+/*=============================================================================
+ Copyright (c) 2007 Marco Cecchetti
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#ifndef _BOOST_OVERLOAD_DETAIL_TRAIT_BY_SIGNATURE_HPP_
+#define _BOOST_OVERLOAD_DETAIL_TRAIT_BY_SIGNATURE_HPP_
+
+#include <boost/type_traits/is_same.hpp>
+
+#include "final_overload_base.hpp"
+
+namespace boost{ namespace overloads{ namespace detail{
+
+///////////////////////////////////////////////////////////////////////////////
+// it provides the base that inherits directly by boost::function<Sig>
+// if it's not found returns final_overload_base as type
+
+template<
+ typename Sig,
+ typename Overload,
+ bool FOUND
+ = boost::is_same<Sig, typename Overload::base_type::signature_type >::value
+>
+struct base_by_sig
+{
+ private:
+ typedef typename Overload::base_type base_type;
+ public:
+ typedef typename base_by_sig<Sig, base_type>::type type;
+};
+
+template< typename Sig, typename Overload >
+struct base_by_sig<Sig, Overload, true>
+{
+ typedef typename Overload::base_type type;
+};
+
+template< typename Sig, bool FOUND >
+struct base_by_sig<Sig, final_overload_base, FOUND>
+{
+ typedef final_overload_base type;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// it provedes the index of a signature, and returns -1 if it's not found
+
+template< typename Sig, typename Overload >
+struct index
+{
+ static const unsigned int value = base_by_sig<Sig, Overload>::type::index;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// utility to discover if a given signature is included in an overload
+
+template< typename Sig, typename Overload >
+struct has_signature
+{
+ static const bool value
+ = !( index<Sig, Overload>::value == final_overload_base::index );
+};
+
+} } } // end namespaces
+
+
+#endif // _BOOST_OVERLOAD_DETAIL_TRAIT_BY_SIGNATURE_HPP_
+

Added: sandbox/overload/trunk/boost/overload/overload_impl.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/boost/overload/overload_impl.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,389 @@
+/*=============================================================================
+ Copyright (c) 2007 Marco Cecchetti
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#ifndef _BOOST_OVERLOAD_IMPL_HPP_
+#define _BOOST_OVERLOAD_IMPL_HPP_
+
+#include "detail/overload_base.hpp"
+#include "detail/trait_by_index.hpp"
+#include "detail/trait_by_signature.hpp"
+#include "detail/trait_by_functor.hpp"
+#include "detail/member_function_form.hpp"
+
+#ifdef BOOST_MSVC
+# pragma warning(push)
+# pragma warning(disable: 4127) // conditional expression is constant.
+#endif
+
+// Workaround for MSVC < 8.0 tested on MSVC 7.1
+#if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
+ #include "detail/function_trait.hpp"
+#endif
+
+
+namespace boost{ namespace overloads{
+
+using detail::extent;
+using detail::signature;
+using detail::function;
+using detail::index;
+using detail::has_signature;
+using detail::has_functor_signature;
+
+using detail::const_;
+using detail::non_const;
+
+///////////////////////////////////////////////////////////////////////////////
+// overload class template
+
+template<
+ typename Sig0,
+ BOOST_PP_ENUM_SHIFTED(BOOST_OVERLOAD_LIMIT, OVL_TEMPL_PARAMS, Sig)
+>
+//template< typename Sig0, typename Sig1 = no_signature, ... >
+class overload
+ : public detail::overload_base<0,BOOST_PP_ENUM_PARAMS(BOOST_OVERLOAD_LIMIT, Sig)>
+
+{
+ public:
+ ///////////////////////////////////////////////////////////////////////////
+ // type traits
+ typedef overload<BOOST_PP_ENUM_PARAMS(BOOST_OVERLOAD_LIMIT, Sig)> this_type;
+ typedef
+ detail::overload_base<0,BOOST_PP_ENUM_PARAMS(BOOST_OVERLOAD_LIMIT, Sig)>
+ base_type;
+
+ // static const unsigned int extent = overloads::extent<this_type>::value;
+ static const unsigned int extent;
+
+ template< unsigned int N >
+ struct signature
+ {
+ typedef typename overloads::signature<N, this_type>::type type;
+ };
+
+ template< unsigned int N >
+ struct function
+ {
+ typedef typename overloads::function< N, this_type >::type type;
+ };
+
+ template< typename Sig >
+ struct index
+ {
+ static const unsigned int value
+ = overloads::index<Sig, this_type>::value;
+ };
+
+ template< typename Sig >
+ struct has_signature
+ {
+ static const bool value
+ = overloads::has_signature<Sig, this_type>::value;
+ };
+
+ template< typename F >
+ struct has_functor_signature
+ {
+ static const bool value
+ = overloads::has_functor_signature<F, this_type>::value;
+ };
+
+ private:
+ ///////////////////////////////////////////////////////////////////////////
+ // Workaround for MSVC < 8.0 tested on MSVC 7.1
+ // types used in the declaration of the function call operators
+
+#if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
+ typedef
+ typename detail::zero_arity_signature<
+ BOOST_PP_ENUM_PARAMS(BOOST_OVERLOAD_LIMIT, Sig)
+ >::type
+ zero_arity_signature_type;
+
+ BOOST_PP_REPEAT(BOOST_OVERLOAD_LIMIT, OVL_REAL_OR_DUMMY_SIG_M, unused)
+#endif
+
+ public:
+ overload()
+ {
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // constructors and methods that supports signature deduction
+
+ BOOST_PP_REPEAT_FROM_TO(1, BOOST_OVERLOAD_LIMIT, OVL_CTOR, unused)
+
+ template< typename F >
+ this_type& set( F const& _f,
+ typename boost::disable_if<
+ boost::is_pointer<F>
+ >::type* = 0 )
+ {
+ set_impl(_f);
+ return *this;
+ }
+
+ BOOST_PP_REPEAT_FROM_TO(2, BOOST_OVERLOAD_LIMIT, OVL_SET, unused)
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Workaround for MSVC < 8.0 tested on MSVC 7.1
+ // function call operators
+
+#if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
+ typename detail::func_trait< zero_arity_signature_type >::result_type
+ operator() ()
+ {
+ return boost::function<zero_arity_signature_type>::operator()();
+ }
+
+ BOOST_PP_REPEAT_FROM_TO(0, BOOST_OVERLOAD_LIMIT, OVL_FUNC_CALL_OPERATORS, Sig)
+#endif
+
+ ///////////////////////////////////////////////////////////////////////////
+ // swap two boost::functions
+
+ template< typename Sig >
+ void swap_function( boost::function<Sig>& _f )
+ {
+ boost::function<Sig>::swap(_f);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // clear all the callable targets
+
+ void clear_all()
+ {
+ clear_all_impl<typename this_type::base_type>(this);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // return true if all the callable targets are empty
+
+ bool empty_all()
+ {
+ return empty_all_impl<typename this_type::base_type>(this);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // signature based methods
+
+ template< typename Sig >
+ const boost::function<Sig>& get() const
+ {
+ return *this;
+ }
+
+ template< typename Sig >
+ boost::function<Sig>& get()
+ {
+ return *this;
+ }
+
+ template<typename Sig>
+ this_type& set( Sig* _f_ptr )
+ {
+ get<Sig>() = _f_ptr;
+ return *this;
+ }
+
+ template<typename Sig>
+ this_type& set( typename detail::memb_func_form<Sig>::type _mf_ptr )
+ {
+ get<Sig>() = _mf_ptr;
+ return *this;
+ }
+
+ template<typename Sig>
+ this_type& set( typename detail::memb_func_form<Sig, const_>::type _mf_ptr )
+ {
+ get<Sig>() = _mf_ptr;
+ return *this;
+ }
+
+ template<typename Sig, typename const_qlf >
+ this_type& set( typename detail::memb_func_form<Sig, const_qlf>::type _mf_ptr )
+ {
+ get<Sig>() = _mf_ptr;
+ return *this;
+ }
+
+ template< typename Sig, typename F >
+ this_type& set( F const& _f,
+ typename boost::disable_if<
+ detail::is_ptr_or_memb_ptr<F>
+ >::type* = 0 )
+ {
+ get<Sig>() = _f;
+ return *this;
+ }
+
+ template< typename Sig >
+ bool empty() const
+ {
+ return boost::function<Sig>::empty();
+ }
+
+ template< typename Sig >
+ void clear()
+ {
+ boost::function<Sig>::clear();
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // index based methods
+
+ template< unsigned int N >
+ const typename function<N>::type& get() const
+ {
+ return *this;
+ }
+
+ template< unsigned int N >
+ typename function<N>::type& get()
+ {
+ return *this;
+ }
+
+ template< unsigned int N, typename F >
+ this_type& set( F const& _f )
+ {
+ get<N>() = _f;
+ return *this;
+ }
+
+ template< unsigned int N >
+ bool empty() const
+ {
+ typedef typename function<N>::type function_type;
+ return function_type::empty();
+ }
+
+ template< unsigned int N >
+ void clear()
+ {
+ typedef typename function<N>::type function_type;
+ function_type::clear();
+ }
+
+ private:
+ ///////////////////////////////////////////////////////////////////////////
+ // function set_impl
+ //
+
+ template< typename Sig >
+ void set_impl( boost::function<Sig> const& _f )
+ {
+ boost::function<Sig>::operator=(_f);
+ }
+
+ template< typename F >
+ void set_impl(
+ F const& _f,
+ typename boost::enable_if< has_functor_signature<F> >::type* = 0
+ )
+ {
+ typedef
+ typename
+ detail::base_by_functor<F, this_type>::type
+ base_type;
+
+ set_impl<F, base_type>(_f, this);
+ }
+
+ template< typename F, typename Base >
+ void set_impl( F const& _f, Base const* )
+ {
+ //std::cout << "set_impl" << std::endl;
+ typedef
+ typename
+ detail::base_by_functor<F, Base>::type
+ base_type;
+ typedef typename Base::signature_type signature_type;
+
+ set<signature_type>(_f);
+ set_impl<F, base_type>(_f, this);
+ }
+
+ template< typename F, typename Base>
+ void set_impl( F const& ,
+ detail::final_overload_base const* )
+ {
+ //std::cout << "final" << std::endl;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // function clear_all__impl
+
+ template< typename Base >
+ void clear_all_impl(Base const* )
+ {
+ typedef typename Base::base_type base_type;
+ typedef typename Base::signature_type signature_type;
+
+ clear<signature_type>();
+ clear_all_impl<base_type>(this);
+ }
+
+ template<typename Base>
+ void clear_all_impl(detail::final_overload_base const* )
+ {
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // function empty_all__impl
+
+ template< typename Base >
+ bool empty_all_impl(Base const* )
+ {
+ typedef typename Base::base_type base_type;
+ typedef typename Base::signature_type signature_type;
+
+ return ( empty<signature_type>() && empty_all_impl<base_type>(this) );
+ }
+
+ template<typename Base>
+ bool empty_all_impl(detail::final_overload_base const*)
+ {
+ return true;
+ }
+ ///////////////////////////////////////////////////////////////////////////
+ // return a pointer to this object casted to the correct base pointer
+ // for a generic functor
+
+ template< typename F >
+ boost::function<typename detail::signature_by_functor<F, this_type>::type>*
+ base_ptr( F const& )
+ {
+ return this;
+ }
+
+}; // end class overload
+
+// defined out of the class for compatibility with gcc 3.4 and intel 9.1
+template< BOOST_PP_ENUM_PARAMS(BOOST_OVERLOAD_LIMIT, typename Sig) >
+const unsigned int
+overload<BOOST_PP_ENUM_PARAMS(BOOST_OVERLOAD_LIMIT, Sig)>::extent
+ = overloads::extent<
+ overload<BOOST_PP_ENUM_PARAMS(BOOST_OVERLOAD_LIMIT, Sig)>
+ >::value;
+
+} // end overloads namespace
+
+using overloads::overload;
+
+} // end boost namespace
+
+
+#ifdef BOOST_MSVC
+# pragma warning(pop)
+#endif
+
+#endif // _BOOST_OVERLOAD_IMPL_HPP_
+
+

Added: sandbox/overload/trunk/libs/overload/docs/README_FIRST.txt
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/docs/README_FIRST.txt 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,166 @@
+
+BOOST OVERLOAD (updated 2007/10/28)
+
+=================================================================
+Copyright (c) 2007 Marco Cecchetti
+
+Use, modification and distribution of this library is
+subject to the Boost Software License, Version 1.0 .
+(See accompanying file LICENSE_1_0.txt or
+copy at http://www.boost.org/LICENSE_1_0.txt)
+=================================================================
+
+=================================================================
+WARNING
+this library is a proof of concept implementation only,
+and it comes without ABSOLUTELY ANY WARRANTY !
+=================================================================
+
+WARNING: at present Boost Overload IS NOT a Boost library !
+===========================================================
+
+=================================================================
+Please report any bugs, compiler issues, comment or suggestion
+to mrcekets_at_[hidden]
+=================================================================
+
+Library Description
+===================
+Boost Overload behaves as an overloaded Boost Function.
+Actually it wraps multiple Boost Function objects of different
+signatures.
+
+Library Documentation
+=====================
+http://docs.google.com/View?docid=dhd386mp_16gxsfxn
+
+Library Tutorial
+================
+http://docs.google.com/Doc?id=dfxvjncs_1x6456m
+
+
+**************************************
+* version 0.3.0 (overload-0.3.0.zip) *
+**************************************
+
+tested with boost version: 1.33.1, 1.34.1
+
+Compiler support table
+======================
+
+compiler OS test
+-------------------------------------------
+gcc 4.1.2 under Linux pass
+intel 9.1 under Linux pass
+mingw 3.4.2 under Windows pass
+mingw 3.2.3 under Windows fail
+MS VC++ 8.0 under Windows pass
+MS VC++ 7.1 under Windows partial*
+
+*all test passed but signature deduction of multi-signature function objects
+you have to use the signature based syntax with them.
+
+what's new
+===========
+
+- added partial support for MSVC 7.1, all work but signature deduction of
+ multi-signature function objects, you have to use the signature based syntax
+ in order to set multi-signature function objects as callable targets;
+
+- you can set a free function overload or a member function
+ overload as callable target through the signature based syntax
+ for more info give a look to the new paragraph in the tuturial;
+ the same applies to template free functions and template member functions;
+
+- added two new helper methods
+ - the empty_all method that tell us if all callable targets are
+ empty;
+ - the clear_all method that clears all the callable targets;
+
+- in the folder libs/overload/example you can find all the examples
+ presented in the tutorial;
+
+- fixed some minor issue.
+
+
+**************************************
+* version 0.2.2 (overload-0.2.2.zip) *
+**************************************
+
+tested with boost version: 1.33.1, 1.34.1
+
+Compiler support table
+======================
+
+compiler OS test
+-------------------------------------------
+gcc 4.1.2 under Linux pass
+intel 9.1 under Linux pass
+mingw 3.4.2 under Windows pass
+mingw 3.2.3 under Windows fail
+MS VC++ 8.0 under Windows pass
+MS VC++ 7.1 under Windows fail
+
+
+description
+===========
+I went on working on the second implementation only.
+The source code has gone through refactoring and modularization.
+The signature deduction policy used by the "set" method is changed in the
+part concerned with multi-signature function objects.
+This is a complete and detailed description of the signature deduction policy:
+
+Let be "ov" an instantiation of the template class overload for
+a given set of signatures "ss" used as template arguments:
+- if the new candidate callable target "f" is a free function or
+ a member function then:
+ - if "f" is not overloaded and its signature is included in "ss"
+ then the new target (i.e. "f") replaces the target tied
+ to the matching signature;
+ - if the signature of "f" is not included in "ss" a compile time
+ error is produced;
+ - if "f" is overloaded an "unresolved overloaded function type"
+ compile time error is produced; (we can't rely on the Mesonides'
+ trick, or equivalent for free functions, because they require
+ to know the function name in advance); this is the same behaviour
+ followed by boost.function;
+ note: when I say that a function member signature is included in
+ "ss" I actually mean that a const or non-const explicit signature
+ of the given member function is included in "ss";
+- if the new candidate callable target "f" is a function object (possibly a
+ multi-signature one ) then:
+ - let be "rs" the set of signatures that are defined by its overload
+ resolution set (or it would be better to say "by the overload
+ resolution set of f::operator()" ); note that for a function
+ object with a template operator() "rs" is an infinite set;
+ - if the intersection between "rs" and "ss" is empty the assignment
+ fails and a compile time error is produced;
+ - if the intersection between "rs" and "ss" is not empty then the new
+ target (i.e. "f") replaces all the targets related to the
+ signatures included in the intersection.
+
+
+**********************************
+* version 0.1 (overload-0.1.zip) *
+**********************************
+
+tested on gcc 4.1.2 under Linux
+
+description
+===========
+The archive includes two implementations.
+
+- in the first implementation, I deduce function object signature
+by exploiting template function argument deduction;
+if the signature is not discovered no error is reported,
+and error handling is demanded to boost::function at call time;
+signature deduction of multi-signature function objects cause
+an "unresolved overloaded function type" compile error;
+
+- in the second implementation, if the signature is not deduced
+a compile time error is produced;
+signature deduction of multi-signature function objects
+is successfull if it exists one and only one signature registered
+in the overload that matches with the function object, else
+an ad-hoc compile time error, pointing out the ambiguity,
+is produced.

Added: sandbox/overload/trunk/libs/overload/examples/example_1.cpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/examples/example_1.cpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,40 @@
+/*=============================================================================
+ Boost Overload
+ Example 1 - Basic usage
+==============================================================================*/
+
+
+#include <boost/detail/lightweight_test.hpp>
+
+#include "../../../boost/overload/overload.hpp"
+
+
+using boost::overload;
+
+
+int int_sum(int x, int y)
+{
+ return x + y;
+}
+
+float float_inc(float x )
+{
+ return x + 1.0f;
+}
+
+int main()
+{
+ overload<int (int, int ), float (float )> f;
+
+ f.set(&int_sum); // here automatic signature
+ f.set(&float_inc); // deduction occurs
+
+ int r1 = f(1, 2); // calls int_sum
+ float r2 = f(3.0f); // calls float_inc
+
+ BOOST_ASSERT(r1 == 3);
+ BOOST_ASSERT(r2 == 4.0f);
+
+ return boost::report_errors();
+}
+

Added: sandbox/overload/trunk/libs/overload/examples/example_2.cpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/examples/example_2.cpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,99 @@
+/*=============================================================================
+ Boost Overload
+ Example 2 - Using different types of callable entities
+==============================================================================*/
+
+
+#include <string>
+
+#include <boost/detail/lightweight_test.hpp>
+
+#include "../../../boost/overload/overload.hpp"
+
+
+using boost::overload;
+
+
+/* free function */
+void foo1(std::string s1, std::string s2, std::string s3)
+{
+ std::cout << s1 << s2 << s3 << std::endl;
+}
+typedef void signature1_t (std::string , std::string , std::string );
+
+/* member function */
+struct bar2
+{
+ int foo2(char )
+ {
+ return 123;
+ }
+};
+typedef int signature2_t (bar2*, char ); // explicit non-const signature
+
+/* free function that will be wrapped by a boost::function */
+char bar3(std::string )
+{
+ return 'x';
+}
+typedef char signature3_t (std::string );
+
+/* class type function */
+struct bar4
+{
+ double operator() (int, char ) const
+ {
+ return 123.456;
+ }
+};
+typedef double signature4_t (int, char );
+
+/* another class type function */
+struct bar5
+{
+ int operator() (char )
+ {
+ return 123;
+ }
+};
+typedef int signature5_t (char );
+
+
+int main()
+{
+ overload<signature1_t, signature2_t,
+ signature3_t, signature4_t, signature5_t> f;
+
+ /* instance that will be used for invoking the member function */
+ bar2 b2;
+ /* boost::function object that uses bar3 as callable target */
+ boost::function<signature3_t> foo3(&bar3);
+ /* function object */
+ bar4 foo4;
+ /* function object that will be wrapped with boost::ref */
+ bar5 foo5;
+
+
+ f.set(&foo1);
+ f.set(&bar2::foo2);
+ // sets the callable target of foo3 as callable target of f
+ // tied to the signature 3
+ f.set(foo3);
+ f.set(foo4);
+ f.set(boost::ref(foo5));
+
+
+ f("Hello", " ", "world !"); // calls foo1 and print "Hello world !"
+ int r2 = f(&b2, 'x'); // calls b2.foo2
+ char r3 = f("hi"); // calls bar3
+ double r4 = f(1, 'x'); // calls foo4
+ int r5 = f('x'); // calls foo5
+
+ BOOST_ASSERT(r2 == 123);
+ BOOST_ASSERT(r3 == 'x' );
+ BOOST_ASSERT(r4 > 123.455 && r4 < 123.457);
+ BOOST_ASSERT(r5 == 123);
+
+ return boost::report_errors();
+}
+

Added: sandbox/overload/trunk/libs/overload/examples/example_3.cpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/examples/example_3.cpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,58 @@
+/*=============================================================================
+ Boost Overload
+ Example 3 - Overloaded function object
+==============================================================================*/
+
+
+#include <string>
+
+#include <boost/detail/lightweight_test.hpp>
+
+#include "../../../boost/overload/overload.hpp"
+
+
+using boost::overload;
+
+
+char foo2(std::string )
+{
+ return 'x';
+}
+
+struct bar
+{
+ double operator() (float x)
+ {
+ return x + 1;
+ }
+
+ double operator() (float x, float y)
+ {
+ return x + y;
+ }
+};
+
+int main()
+{
+ overload<char (std::string ), double (float ), double (float, float )> f;
+
+ bar foo;
+
+
+ f.set(foo); // sets foo as callable target for both the signature double (float )
+ // and the signature double (float, float )
+
+
+ f.set(&foo2);
+
+ char r1 = f("hi");
+ double r2 = f(1.0f); // calls the double foo(float ) overload
+ double r3 = f(2.0f, 3.0f); // calls the double foo(float, float ) overload
+
+ BOOST_ASSERT(r1 == 'x');
+ BOOST_ASSERT(r2 == 2.0);
+ BOOST_ASSERT(r3 == 5.0);
+
+ return boost::report_errors();
+}
+

Added: sandbox/overload/trunk/libs/overload/examples/example_4.cpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/examples/example_4.cpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,52 @@
+/*=============================================================================
+ Boost Overload
+ Example 4 - Template function object
+==============================================================================*/
+
+
+#include <string>
+
+#include <boost/detail/lightweight_test.hpp>
+
+#include "../../../boost/overload/overload.hpp"
+
+
+using boost::overload;
+
+
+char foo2(std::string )
+{
+ return 'x';
+}
+
+struct bar
+{
+ template<typename T>
+ T operator()(T x)
+ {
+ return x + 1;
+ }
+};
+
+int main()
+{
+ overload<char (std::string ), int (int ), double (double )> f;
+
+ bar foo;
+
+ f.set(foo); // sets foo as callable target for both the signature int (int )
+ // and the signature double (double )
+
+ f.set(&foo2);
+
+ char r1 = f("hi");
+ int r2 = f(1); // calls int foo(int ) template instantiation
+ double r3 = f(2.0); // calls double foo(double ) template instantiation
+
+ BOOST_ASSERT(r1 == 'x');
+ BOOST_ASSERT(r2 == 2);
+ BOOST_ASSERT(r3 == 3.0);
+
+ return boost::report_errors();
+}
+

Added: sandbox/overload/trunk/libs/overload/examples/example_5.cpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/examples/example_5.cpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,48 @@
+/*=============================================================================
+ Boost Overload
+ Example 5 - Using the signature based syntax
+ with multi-signature function objects
+==============================================================================*/
+
+
+#include <string>
+
+#include <boost/detail/lightweight_test.hpp>
+
+#include "../../../boost/overload/overload.hpp"
+
+
+using boost::overload;
+
+
+struct bar
+{
+ template<typename T>
+ T operator()(T x)
+ {
+ return x;
+ }
+};
+
+int main()
+{
+ overload<int (int ), std::string (std::string )> f;
+
+ bar foo;
+
+ f.set<int (int )>(foo); // we are using the signature syntax that sets foo
+ // as callable target for the signature int (int ) only
+
+ int r1 = f(1); // calls int foo(int ) template instantiation
+
+ /* Warning !!
+ This call produces a comiler error because there is no callable target
+ tied to the "std::string (std::string )" signature
+ std:string r2 = f( std::string("hi") );
+ */
+
+ BOOST_ASSERT(r1 == 1);
+
+ return boost::report_errors();
+}
+

Added: sandbox/overload/trunk/libs/overload/examples/example_6.cpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/examples/example_6.cpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,56 @@
+/*=============================================================================
+ Boost Overload
+ Example 6 - Using helper methods
+==============================================================================*/
+
+
+#include <string>
+
+#include <boost/detail/lightweight_test.hpp>
+
+#include "../../../boost/overload/overload.hpp"
+
+
+using boost::overload;
+
+
+void foo1(std::string s1, std::string s2, std::string s3)
+{
+ std::cout << s1 << s2 << s3 << std::endl;
+}
+typedef void signature1_t (std::string , std::string , std::string );
+
+
+int foo2(int x)
+{
+ return x + 1;
+}
+typedef int signature2_t (int );
+
+
+int main()
+{
+ overload<signature1_t, signature2_t> f(&foo1, &foo2);
+
+ f("Hello", " ", "world !"); // print "Hello world !"
+
+ f.clear<signature1_t>();
+ BOOST_ASSERT( f.empty<signature1_t>() ); // f has no callable target
+ // associated with signature 1
+
+ boost::function<signature1_t> g(&foo1); // g has foo1 as callable target
+ f.swap_function(g); // after swapping f has foo1
+ // as callable target
+ f("I'm ", "back ", "again !"); // associated with signature 1
+ BOOST_ASSERT( g.empty() ); // and g has no callable target
+
+ g = f.get<signature1_t>(); // g is set to the embedded object
+ g("That's ", "all ", "folks !"); // of f with type
+ // boost::function<signature1_t>
+
+ f.clear_all(); // now f has no callable target
+ BOOST_ASSERT( f.empty_all() ); // associated to any signature
+
+ return boost::report_errors();
+}
+

Added: sandbox/overload/trunk/libs/overload/examples/example_7a.cpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/examples/example_7a.cpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,42 @@
+/*=============================================================================
+ Boost Overload
+ Example 7a - Setting a free function overload as callable target
+==============================================================================*/
+
+
+#include <string>
+
+#include <boost/detail/lightweight_test.hpp>
+
+#include "../../../boost/overload/overload.hpp"
+
+
+using boost::overload;
+
+
+int foo(int )
+{
+ return 1;
+}
+
+int foo(std::string )
+{
+ return 2;
+}
+
+int main()
+{
+ overload<int (int ), int (std::string )> f;
+
+ int (*foo1) (int ) = &foo;
+ int (*foo2) (std::string ) = &foo;
+
+ f.set(foo1);
+ f.set(foo2);
+
+ BOOST_ASSERT( f(0) == 1 );
+ BOOST_ASSERT( f("hi") == 2 );
+
+ return boost::report_errors();
+}
+

Added: sandbox/overload/trunk/libs/overload/examples/example_7b.cpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/examples/example_7b.cpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,41 @@
+/*=============================================================================
+ Boost Overload
+
+ Example 7b - Setting a free function overload as callable target
+==============================================================================*/
+
+
+#include <string>
+
+#include <boost/detail/lightweight_test.hpp>
+
+#include "../../../boost/overload/overload.hpp"
+
+
+using boost::overload;
+
+
+int foo(int )
+{
+ return 1;
+}
+
+int foo(std::string )
+{
+ return 2;
+}
+
+int main()
+{
+ overload<int (int ), int (std::string )> f;
+
+ // disambiguation through the signature based sintax
+ f.set<int (int )>(&foo);
+ f.set<int (std::string )>(&foo);
+
+ BOOST_ASSERT( f(0) == 1 );
+ BOOST_ASSERT( f("hi") == 2 );
+
+ return boost::report_errors();
+}
+

Added: sandbox/overload/trunk/libs/overload/examples/example_8a.cpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/examples/example_8a.cpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,47 @@
+/*=============================================================================
+ Boost Overload
+ Example 8a - Setting a member function overload as callable target
+==============================================================================*/
+
+
+#include <string>
+
+#include <boost/detail/lightweight_test.hpp>
+
+#include "../../../boost/overload/overload.hpp"
+
+
+using boost::overload;
+
+
+struct bar
+{
+ int foo(int )
+ {
+ return 1;
+ }
+
+ int foo(std::string )
+ {
+ return 2;
+ }
+};
+
+int main()
+{
+ overload<int (bar*, int ), int (bar*, std::string )> f;
+
+ bar b;
+
+ int (bar::*foo1) (int ) = &bar::foo;
+ int (bar::*foo2) (std::string ) = &bar::foo;
+
+ f.set(foo1);
+ f.set(foo2);
+
+ BOOST_ASSERT( f(&b, 0) == 1 );
+ BOOST_ASSERT( f(&b, "hi") == 2 );
+
+ return boost::report_errors();
+}
+

Added: sandbox/overload/trunk/libs/overload/examples/example_8b.cpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/examples/example_8b.cpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,45 @@
+/*=============================================================================
+ Boost Overload
+ Example 8b - Setting a member function overload as callable target
+==============================================================================*/
+
+
+#include <string>
+
+#include <boost/detail/lightweight_test.hpp>
+
+#include "../../../boost/overload/overload.hpp"
+
+
+using boost::overload;
+
+
+struct bar
+{
+ int foo(int )
+ {
+ return 1;
+ }
+
+ int foo(std::string )
+ {
+ return 2;
+ }
+};
+
+int main()
+{
+ overload<int (bar*, int ), int (bar*, std::string )> f;
+
+ bar b;
+
+ // disambiguation through the signature based sintax
+ f.set<int (bar*, int )>(&bar::foo);
+ f.set<int (bar*, std::string )>(&bar::foo);
+
+ BOOST_ASSERT( f(&b, 0) == 1 );
+ BOOST_ASSERT( f(&b, "hi") == 2 );
+
+ return boost::report_errors();
+}
+

Added: sandbox/overload/trunk/libs/overload/tests/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/tests/Jamfile.v2 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,16 @@
+# Copyright 2007 (c) Dean Michael Berris, Marco Ceccheti
+# Released under the Boost Software License Version 1.0
+# See http://boost.org/LICENSE_1_0.txt for full license text.
+
+import modules ;
+
+local BOOST_DIR = [ modules.peek : BOOST_ROOT ] ;
+
+project overload/tests
+ : requirements
+ <include>../../../
+ <include>$(BOOST_DIR)
+ ;
+
+unit-test initial_test : test.cpp ;
+

Added: sandbox/overload/trunk/libs/overload/tests/test.cpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/tests/test.cpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,39 @@
+
+#include <iostream>
+
+
+
+#include <boost/type_traits/is_same.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+
+#include <boost/overload.hpp>
+
+#include "test/functors.hpp"
+
+
+namespace ovld = boost::overloads;
+namespace ovdtl = boost::overloads::detail;
+using boost::is_same;
+
+
+
+
+#include "test/trait_by_index.hpp"
+#include "test/trait_by_signature.hpp"
+#include "test/trait_by_functor.hpp"
+#include "test/signature_deduction.hpp"
+#include "test/idx_and_sig_methods.hpp"
+#include "test/free_and_member_functions.hpp"
+#include "test/signature_with_ptr_ref.hpp"
+
+int main()
+{
+ test05();
+ test06();
+ test07();
+ test08();
+ return boost::report_errors();
+}
+

Added: sandbox/overload/trunk/libs/overload/tests/test/free_and_member_functions.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/tests/test/free_and_member_functions.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,87 @@
+
+#ifndef _TEST_FREE_AND_MEMBER_OVERLOADED_FUNCTIONS_HPP_
+#define _TEST_FREE_AND_MEMBER_OVERLOADED_FUNCTIONS_HPP_
+
+
+void test07()
+{
+ typedef
+ boost::overload<inc_int_sig_t, inc_float_sig_t,
+ foo_int_sig_t, foo_float_sig_t>
+ overload_type;
+
+ overload_type f;
+
+ multi multi1;
+
+ f.set<inc_int_sig_t>(&inc); // uses "int inc(int )"
+ f.set<inc_float_sig_t>(&inc); // uses "float inc(float )"
+ f.set<foo_int_sig_t, ovld::non_const>(&multi::foo); // uses "int foo(int )"
+ f.set<foo_float_sig_t>(&multi::foo); // uses "float foo(std::string )"
+
+ BOOST_ASSERT( f(1) == 2 );
+ BOOST_ASSERT( f(2.0f) == 3.0f );
+ BOOST_ASSERT( f(&multi1, 1) == 1 );
+ BOOST_ASSERT( f(&multi1, "hi") == 3.0f );
+
+ // uses "int foo(int ) const"
+ f.set<foo_int_sig_t, ovld::const_>(&multi::foo);
+ BOOST_ASSERT( f(&multi1, 1) == 2 );
+
+
+
+ boost::overload<foo_int_const_sig_t, foo_float_sig_t> g;
+
+ // uses "int foo(int ) const" because it's the only valid choice
+ g.set<foo_int_const_sig_t>(&multi::foo);
+ BOOST_ASSERT( g(&multi1, 1) == 2 );
+
+ // you can utilize the explicit syntax, too:
+ // g.set<foo_int_const_sig_t, ovld::const_>(&multi1::foo);
+
+
+
+ typedef double non_const_sig2_t (bar2*, int, char );
+ boost::overload<sig1_t, non_const_sig2_t> qui;
+ bar1 b1;
+ bar2 b2;
+ qui.set<sig1_t>(&bar1::foo1);
+ qui.set<non_const_sig2_t>(&bar2::foo2);
+ BOOST_ASSERT( qui(&b1, 'x') == 123 );
+ BOOST_ASSERT( qui(&b2, 1, 'x') == 123.456 );
+ qui.clear<non_const_sig2_t>();
+ qui.set<non_const_sig2_t, ovld::const_>(&bar2::foo2);
+ BOOST_ASSERT( qui(&b2, 1, 'x') == 123.456 );
+
+
+
+ boost::overload<sig1_t, sig2_t> quo;
+ quo.set<sig1_t>(&bar1::foo1);
+ quo.set<sig2_t>(&bar2::foo2);
+ BOOST_ASSERT( quo(&b1, 'x') == 123 );
+ BOOST_ASSERT( quo(&b2, 1, 'x') == 123.456 );
+ quo.clear<sig2_t>();
+ quo.set<sig2_t, ovld::const_>(&bar2::foo2);
+ BOOST_ASSERT( quo(&b2, 1, 'x') == 123.456 );
+
+
+
+ boost::overload<int (int, int), int (int, std::string )> qua;
+ qua.set<int (int, std::string )>(&foo12);
+ qua.set<int (int, int )>(&foo12);
+ BOOST_ASSERT( qua(1, 1) == 12 );
+ BOOST_ASSERT( qua(1, std::string("hi")) == 122 );
+
+
+
+ boost::overload<int (bar13*, int, int), int (bar13*, int, std::string )> duck;
+ bar13 b13;
+ duck.set<int (bar13*, int, int)>(&bar13::foo13);
+ duck.set<int (bar13*, int, std::string )>(&bar13::foo13);
+ BOOST_ASSERT( duck(&b13, 1, 1) == 13 );
+ BOOST_ASSERT( duck(&b13, 1, std::string("hi")) == 133 );
+}
+
+
+#endif // _TEST_FREE_AND_MEMBER_OVERLOADED_FUNCTIONS_HPP_
+

Added: sandbox/overload/trunk/libs/overload/tests/test/functors.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/tests/test/functors.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,223 @@
+
+#ifndef _FUNCTORS_HPP_
+#define _FUNCTORS_HPP_
+
+
+#include <string>
+#include <iostream>
+#include <boost/function.hpp>
+
+///////////////////////////////////////////////////////////////////////////////
+void foo0(std::string s1, std::string s2, std::string s3)
+{
+ std::cout << s1 << s2 << s3 << std::endl;
+}
+
+typedef void sig0_t (std::string , std::string , std::string );
+typedef sig0_t* f0_t;
+
+///////////////////////////////////////////////////////////////////////////////
+struct bar1
+{
+ int foo1(char )
+ {
+ return 123;
+ }
+};
+
+typedef int sig1_t (bar1*, char );
+typedef int (bar1::* f1_t) (char );
+
+///////////////////////////////////////////////////////////////////////////////
+struct bar2
+{
+ double foo2(int, char ) const
+ {
+ return 123.456;
+ }
+};
+
+typedef double sig2_t (const bar2*, int, char );
+typedef double (bar2::* f2_t) (int, char ) const;
+
+///////////////////////////////////////////////////////////////////////////////
+char foo3(std::string )
+{
+ return 'x';
+}
+
+typedef char sig3_t (std::string );
+typedef boost::function<sig3_t> f3_t;
+
+
+///////////////////////////////////////////////////////////////////////////////
+struct foo4
+{
+ int operator() (char )
+ {
+ return 123;
+ }
+};
+
+typedef int sig4_t (char );
+typedef foo4 f4_t;
+
+///////////////////////////////////////////////////////////////////////////////
+struct foo5
+{
+ double operator() (int, char ) const
+ {
+ return 123.456;
+ }
+};
+
+typedef double sig5_t (int, char );
+typedef foo5 f5_t;
+
+///////////////////////////////////////////////////////////////////////////////
+struct foo6
+{
+ double operator() (float x)
+ {
+ return x + 1;
+ }
+
+ double operator() (float x, float y)
+ {
+ return x + y;
+ }
+};
+
+typedef double sig6_t (float );
+typedef double sig7_t (float, float );
+typedef foo6 f6_t;
+
+///////////////////////////////////////////////////////////////////////////////
+struct foo7
+{
+ template<typename T>
+ T operator()(T x)
+ {
+ return x + 1;
+ }
+};
+
+typedef int sig8_t (int );
+typedef double sig9_t (double );
+typedef foo7 f7_t;
+
+///////////////////////////////////////////////////////////////////////////////
+int foo8( double & )
+{
+ return 8;
+}
+
+typedef int sig10_t (double& );
+typedef sig10_t* f8_t;
+
+///////////////////////////////////////////////////////////////////////////////
+struct bar9
+{
+ int foo9( double** )
+ {
+ return 9;
+ }
+
+ int foo10( double* const& ) const
+ {
+ return 10;
+ }
+};
+typedef int sig11_t (bar9*, double** );
+typedef int (bar9::* f9_t) (double** );
+typedef int sig12_t (bar9*, double* const& );
+typedef int (bar9::* f10_t) (const double* & ) const;
+
+///////////////////////////////////////////////////////////////////////////////
+struct bar11
+{
+ int foo11( double** ) const
+ {
+ return 11;
+ }
+};
+typedef int sig13_t (bar11*, double** );
+typedef int (bar11::* f11_t) ( double** ) const;
+
+///////////////////////////////////////////////////////////////////////////////
+int foo12(int, int )
+{
+ return 12;
+}
+
+template<typename T1, typename T2>
+T1 foo12(T1, T2 )
+{
+ return 122;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+struct bar13
+{
+ int foo13(int, int )
+ {
+ return 13;
+ }
+
+ template<typename T1, typename T2>
+ T1 foo13(T1, T2 )
+ {
+ return 133;
+ }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+struct foo14
+{
+ template< typename T1, typename T2 >
+ int operator() ( T1, T2 )
+ {
+ return sizeof(T2);
+ }
+};
+typedef foo14 f14_t;
+
+///////////////////////////////////////////////////////////////////////////////
+int inc(int x)
+{
+ return x + 1;
+}
+
+float inc(float x )
+{
+ return x + 1;
+}
+typedef int inc_int_sig_t (int );
+typedef float inc_float_sig_t (float );
+
+///////////////////////////////////////////////////////////////////////////////
+struct multi
+{
+ int foo(int )
+ {
+ return 1;
+ }
+
+ int foo(int ) const
+ {
+ return 2;
+ }
+
+ float foo(std::string )
+ {
+ return 3.0f;
+ }
+};
+typedef int foo_int_sig_t (multi*, int );
+typedef int foo_int_const_sig_t (const multi*, int );
+typedef float foo_float_sig_t (multi*, std::string );
+
+
+
+#endif // _FUNCTORS_HPP_
+

Added: sandbox/overload/trunk/libs/overload/tests/test/idx_and_sig_methods.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/tests/test/idx_and_sig_methods.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,69 @@
+
+#ifndef TEST_IDX_AND_SIG_METHODS_HPP
+#define TEST_IDX_AND_SIG_METHODS_HPP
+
+void test06()
+{
+ typedef boost::overload<sig0_t, sig1_t, sig2_t, sig3_t, sig4_t,
+ sig5_t, sig6_t, sig7_t, sig8_t, sig9_t>
+ overload_type;
+
+ f0_t f0 = &foo0; // function pointer
+ f1_t f1 = &bar1::foo1; // member function pointer
+ f2_t f2 = &bar2::foo2; // member function pointer (with const)
+ f3_t f3 = &foo3; // boost::function
+ f4_t f4; // function object
+ f5_t f5; // function object (with const)
+ f6_t f6; // overloaded function object
+ f7_t f7; // polymorfic function object
+
+ bar1 b1; bar2 b2;
+
+ overload_type f;
+
+ f.set<0>(f0);
+ f.set<sig1_t>(f1);
+ f.set<5>(f5).set<3>(f3).set<sig4_t>(f4).set<2>(f2);
+ f.set<sig6_t>(f6).set<7>(f6);
+ f.set<sig9_t>(f7).set<sig8_t>(f7);
+
+ f( "Hi", ", ", "people !" );
+
+ int i = f(&b1, 'x');
+ double d1 = f(&b2, 123, 'x');
+ char c = f("hello");
+ int j = f('x');
+ double d2 = f(123, 'x');
+ double d3 = f(2.5f);
+ double d4 = f(3.0f, 4.0f);
+ int k = f(1);
+ double d5 = f(2.5);
+
+ BOOST_ASSERT(i == 123);
+ BOOST_ASSERT(d1 > 123.455 && d1 < 123.457);
+ BOOST_ASSERT(c == 'x');
+ BOOST_ASSERT(j == 123);
+ BOOST_ASSERT(d2 > 123.455 && d2 < 123.457);
+ BOOST_ASSERT(d3 == 3.5);
+ BOOST_ASSERT(d4 == 7.0);
+ BOOST_ASSERT(k == 2);
+ BOOST_ASSERT(d5 == 3.5);
+
+
+ f.clear<sig0_t>(); // same as f.clear<0>()
+ BOOST_ASSERT( f.empty<sig0_t>() ); // same as f.empty<0>()
+
+ boost::function<sig0_t> g(f0);
+ f.swap_function(g);
+ f("I'm ", "back ", "again !");
+ BOOST_ASSERT( g.empty() );
+
+ g = f.get<sig0_t>(); // same as f.get<0>()
+ g("That's ", "all ", "folks !");
+
+}
+
+
+
+#endif // TEST_IDX_AND_SIG_METHODS_HPP
+

Added: sandbox/overload/trunk/libs/overload/tests/test/signature_deduction.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/tests/test/signature_deduction.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,75 @@
+
+#ifndef _TEST_SIGNATURE_DEDUCTION_HPP_
+#define _TEST_SIGNATURE_DEDUCTION_HPP_
+
+
+void test05()
+{
+ typedef boost::overload<sig0_t, sig1_t, sig2_t, sig3_t, sig4_t,
+ sig5_t, sig6_t, sig7_t, sig8_t, sig9_t>
+ overload_type;
+
+ f0_t f0 = &foo0; // function pointer
+ f1_t f1 = &bar1::foo1; // member function pointer
+ f2_t f2 = &bar2::foo2; // member function pointer (with const)
+ f3_t f3 = &foo3; // boost::function
+ f4_t f4; // function object
+ f5_t f5; // function object (with const)
+
+ bar1 b1; bar2 b2;
+
+ overload_type f(f4, f2);
+ f.set(f0, f5, f1, f3);
+
+ f( "Hello", ", ", "world !" );
+
+ int i = f(&b1, 'x');
+ double d1 = f(&b2, 123, 'x');
+ char c = f("hello");
+ int j = f('x');
+ double d2 = f(123, 'x');
+
+ BOOST_ASSERT(i == 123);
+ BOOST_ASSERT(d1 > 123.455 && d1 < 123.457);
+ BOOST_ASSERT(c == 'x');
+ BOOST_ASSERT(j == 123);
+ BOOST_ASSERT(d2 > 123.455 && d2 < 123.457);
+
+
+ //////////////////////////////////////////////////////////////////////////
+ // multi-signature function objects
+
+ // MSVC 7.1 doesn't succeed in deducing the signature of a multi-signature
+ // function object
+#if !BOOST_WORKAROUND(BOOST_MSVC, < 1400)
+
+ f6_t f6; // overloaded function object
+ f7_t f7; // polymorfic function object
+
+ f.set(f7, f6);
+
+ double d3 = f(2.5f);
+ double d4 = f(3.0f, 4.0f);
+ int k = f(1);
+ double d5 = f(2.5);
+
+ BOOST_ASSERT(d3 == 3.5);
+ BOOST_ASSERT(d4 == 7.0);
+ BOOST_ASSERT(k == 2);
+ BOOST_ASSERT(d5 == 3.5);
+
+
+
+ boost::overload<int (int, int), int (int, std::string )> g;
+ f14_t f14;
+ g.set(f14);
+ BOOST_ASSERT( g(1,1) == sizeof(int) );
+ BOOST_ASSERT( g(1, std::string("hi")) == sizeof(std::string) );
+
+#endif
+
+}
+
+
+#endif // _TEST_SIGNATURE_DEDUCTION_HPP_
+

Added: sandbox/overload/trunk/libs/overload/tests/test/signature_with_ptr_ref.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/tests/test/signature_with_ptr_ref.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,44 @@
+
+#ifndef _TEST_SIGNATURE_WITH_PTR_AND_REF_HPP_
+#define _TEST_SIGNATURE_WITH_PTR_AND_REF_HPP_
+
+
+void test08()
+{
+ boost::overload<sig10_t, sig11_t, sig12_t, sig13_t> f;
+
+ bar9 b9;
+ bar11 b11;
+
+ f.set(&foo8);
+ f.set(&bar9::foo9);
+ f.set(&bar9::foo10);
+ f.set(&bar11::foo11);
+
+ double d = 5;
+ double* p = &d;
+
+ BOOST_ASSERT( f(d) == 8 );
+ BOOST_ASSERT( f(&b9, &p) == 9 );
+ BOOST_ASSERT( f(&b9 , p) == 10 );
+ BOOST_ASSERT( f(&b11, &p) == 11 );
+
+ f.clear_all();
+ BOOST_ASSERT( f.empty_all() );
+
+ f.set<sig10_t>(&foo8);
+ f.set<sig11_t>(&bar9::foo9);
+ f.set<sig12_t>(&bar9::foo10);
+ f.set<sig13_t>(&bar11::foo11);
+
+ BOOST_ASSERT( f(d) == 8 );
+ BOOST_ASSERT( f(&b9, &p) == 9 );
+ BOOST_ASSERT( f(&b9 , p) == 10 );
+ BOOST_ASSERT( f(&b11, &p) == 11 );
+
+}
+
+
+
+#endif // _TEST_SIGNATURE_WITH_PTR_AND_REF_HPP_
+

Added: sandbox/overload/trunk/libs/overload/tests/test/trait_by_functor.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/tests/test/trait_by_functor.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,45 @@
+
+#ifndef _TEST_TRAIT_BY_FUNCTOR_HPP_
+#define _TEST_TRAIT_BY_FUNCTOR_HPP_
+
+
+namespace test03 {
+
+typedef boost::overload<sig0_t, sig1_t, sig2_t, sig3_t, sig4_t,
+ sig5_t, sig6_t, sig7_t, sig8_t, sig9_t>
+ overload_type;
+
+BOOST_STATIC_ASSERT(( ovdtl::functor_has_signature<f4_t, sig4_t>::value ));
+
+}
+
+
+namespace test04 {
+
+typedef boost::overload<sig0_t, sig1_t, sig2_t, sig3_t, sig4_t, sig5_t, sig6_t, sig7_t>
+ overload_type;
+
+BOOST_STATIC_ASSERT((
+ is_same<ovdtl::base_by_functor<f0_t, overload_type>::type,
+ overload_type::base_type
+ >::value
+));
+BOOST_STATIC_ASSERT((
+ is_same<ovdtl::signature_by_functor<f5_t, ovdtl::base_by_functor<f0_t, overload_type>::type >::type,
+ sig5_t
+ >::value
+));
+BOOST_STATIC_ASSERT((
+ is_same<ovdtl::function_by_functor<f1_t, overload_type>::type,
+ boost::function<sig1_t>
+ >::value
+));
+BOOST_STATIC_ASSERT(( ovdtl::index_by_functor<f2_t, overload_type>::value == 2 ));
+BOOST_STATIC_ASSERT(( ovdtl::has_functor_signature<f4_t, overload_type>::value ));
+BOOST_STATIC_ASSERT(( !ovdtl::has_functor_signature<f7_t, overload_type>::value ));
+
+}
+
+
+#endif // _TEST_TRAIT_BY_FUNCTOR_HPP_
+

Added: sandbox/overload/trunk/libs/overload/tests/test/trait_by_index.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/tests/test/trait_by_index.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,30 @@
+
+#ifndef _TEST_TRAIT_BY_INDEX_HPP_
+#define _TEST_TRAIT_BY_INDEX_HPP_
+
+
+namespace test01{
+
+typedef boost::overload<sig0_t, sig1_t, sig2_t, sig3_t, sig4_t, sig5_t>
+ overload_type;
+
+BOOST_STATIC_ASSERT(( ovdtl::extent<overload_type>::value == 6 ));
+// MSVC 7.1 doesn't support the syntax overload_type::base_type::base_type::...
+#if !BOOST_WORKAROUND(BOOST_MSVC, < 1400)
+BOOST_STATIC_ASSERT((
+ is_same<ovdtl::base_by_idx<3, overload_type>::type,
+ overload_type::base_type::base_type::base_type::base_type
+ >::value
+));
+#endif
+BOOST_STATIC_ASSERT(( is_same<ovdtl::signature<2,overload_type>::type, sig2_t>::value ));
+BOOST_STATIC_ASSERT((
+ is_same<ovdtl::function<5, overload_type>::type,
+ boost::function<sig5_t>
+ >::value
+));
+
+}
+
+#endif // _TEST_TRAIT_BY_INDEX_HPP_
+

Added: sandbox/overload/trunk/libs/overload/tests/test/trait_by_signature.hpp
==============================================================================
--- (empty file)
+++ sandbox/overload/trunk/libs/overload/tests/test/trait_by_signature.hpp 2007-11-01 11:42:23 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,26 @@
+
+#ifndef _TEST_TRAIT_BY_SIGNATURE_HPP_
+#define _TEST_TRAIT_BY_SIGNATURE_HPP_
+
+
+namespace test02{
+
+typedef boost::overload<sig0_t, sig1_t, sig2_t, sig3_t, sig4_t, sig5_t>
+ overload_type;
+
+// MSVC 7.1 doesn't support the syntax overload_type::base_type::base_type::...
+#if !BOOST_WORKAROUND(BOOST_MSVC, < 1400)
+BOOST_STATIC_ASSERT((
+ is_same<ovdtl::base_by_sig<sig3_t, overload_type>::type,
+ overload_type::base_type::base_type::base_type::base_type
+ >::value
+));
+#endif
+BOOST_STATIC_ASSERT(( ovdtl::index<sig2_t, overload_type>::value == 2 ));
+BOOST_STATIC_ASSERT(( ovdtl::has_signature<sig5_t, overload_type>::value ));
+BOOST_STATIC_ASSERT(( !ovdtl::has_signature<sig6_t, overload_type>::value ));
+
+}
+
+#endif // _TEST_TRAIT_BY_SIGNATURE_HPP_
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk