commit 62db26b94da219566e62acc732b6229bc7652723 Author: Beman Dawes Date: Thu Jun 21 16:19:33 2001 +0000 Initial comit [SVN r10368] diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..3e84d7c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,96 @@ +* text=auto !eol svneol=native#text/plain +*.gitattributes text svneol=native#text/plain + +# Scriptish formats +*.bat text svneol=native#text/plain +*.bsh text svneol=native#text/x-beanshell +*.cgi text svneol=native#text/plain +*.cmd text svneol=native#text/plain +*.js text svneol=native#text/javascript +*.php text svneol=native#text/x-php +*.pl text svneol=native#text/x-perl +*.pm text svneol=native#text/x-perl +*.py text svneol=native#text/x-python +*.sh eol=lf svneol=LF#text/x-sh +configure eol=lf svneol=LF#text/x-sh + +# Image formats +*.bmp binary svneol=unset#image/bmp +*.gif binary svneol=unset#image/gif +*.ico binary svneol=unset#image/ico +*.jpeg binary svneol=unset#image/jpeg +*.jpg binary svneol=unset#image/jpeg +*.png binary svneol=unset#image/png +*.tif binary svneol=unset#image/tiff +*.tiff binary svneol=unset#image/tiff +*.svg text svneol=native#image/svg%2Bxml + +# Data formats +*.pdf binary svneol=unset#application/pdf +*.avi binary svneol=unset#video/avi +*.doc binary svneol=unset#application/msword +*.dsp text svneol=crlf#text/plain +*.dsw text svneol=crlf#text/plain +*.eps binary svneol=unset#application/postscript +*.gz binary svneol=unset#application/gzip +*.mov binary svneol=unset#video/quicktime +*.mp3 binary svneol=unset#audio/mpeg +*.ppt binary svneol=unset#application/vnd.ms-powerpoint +*.ps binary svneol=unset#application/postscript +*.psd binary svneol=unset#application/photoshop +*.rdf binary svneol=unset#text/rdf +*.rss text svneol=unset#text/xml +*.rtf binary svneol=unset#text/rtf +*.sln text svneol=native#text/plain +*.swf binary svneol=unset#application/x-shockwave-flash +*.tgz binary svneol=unset#application/gzip +*.vcproj text svneol=native#text/xml +*.vcxproj text svneol=native#text/xml +*.vsprops text svneol=native#text/xml +*.wav binary svneol=unset#audio/wav +*.xls binary svneol=unset#application/vnd.ms-excel +*.zip binary svneol=unset#application/zip + +# Text formats +.htaccess text svneol=native#text/plain +*.bbk text svneol=native#text/xml +*.cmake text svneol=native#text/plain +*.css text svneol=native#text/css +*.dtd text svneol=native#text/xml +*.htm text svneol=native#text/html +*.html text svneol=native#text/html +*.ini text svneol=native#text/plain +*.log text svneol=native#text/plain +*.mak text svneol=native#text/plain +*.qbk text svneol=native#text/plain +*.rst text svneol=native#text/plain +*.sql text svneol=native#text/x-sql +*.txt text svneol=native#text/plain +*.xhtml text svneol=native#text/xhtml%2Bxml +*.xml text svneol=native#text/xml +*.xsd text svneol=native#text/xml +*.xsl text svneol=native#text/xml +*.xslt text svneol=native#text/xml +*.xul text svneol=native#text/xul +*.yml text svneol=native#text/plain +boost-no-inspect text svneol=native#text/plain +CHANGES text svneol=native#text/plain +COPYING text svneol=native#text/plain +INSTALL text svneol=native#text/plain +Jamfile text svneol=native#text/plain +Jamroot text svneol=native#text/plain +Jamfile.v2 text svneol=native#text/plain +Jamrules text svneol=native#text/plain +Makefile* text svneol=native#text/plain +README text svneol=native#text/plain +TODO text svneol=native#text/plain + +# Code formats +*.c text svneol=native#text/plain +*.cpp text svneol=native#text/plain +*.h text svneol=native#text/plain +*.hpp text svneol=native#text/plain +*.ipp text svneol=native#text/plain +*.tpp text svneol=native#text/plain +*.jam text svneol=native#text/plain +*.java text svneol=native#text/plain diff --git a/include/boost/function.hpp b/include/boost/function.hpp new file mode 100644 index 0000000..24c0942 --- /dev/null +++ b/include/boost/function.hpp @@ -0,0 +1,521 @@ +// Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu) +// +// Permission to copy, use, sell and distribute this software is granted +// provided this copyright notice appears in all copies. +// Permission to modify the code and to distribute modified code is granted +// provided this copyright notice appears in all copies, and a notice +// that the code was modified is included with the copyright notice. +// +// This software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. + +// For more information, see http://www.boost.org + +// William Kempf, Jesse Jones and Karl Nelson were all very helpful in the +// design of this library. + +#ifndef BOOST_FUNCTION_HPP +#define BOOST_FUNCTION_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { + namespace detail { + namespace function { + // Choose the appropriate underlying implementation + template struct real_get_function_impl {}; + + template<> + struct real_get_function_impl<0> + { + template< + typename R, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename Policy = empty_function_policy, + typename Mixin = empty_function_mixin, + typename Allocator = std::allocator + > + struct params + { + typedef function0 type; + }; + }; + + template<> + struct real_get_function_impl<1> + { + template< + typename R, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename Policy = empty_function_policy, + typename Mixin = empty_function_mixin, + typename Allocator = std::allocator + > + struct params + { + typedef function1 type; + }; + }; + + template<> + struct real_get_function_impl<2> + { + template< + typename R, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename Policy = empty_function_policy, + typename Mixin = empty_function_mixin, + typename Allocator = std::allocator + > + struct params + { + typedef function2 type; + }; + }; + + template<> + struct real_get_function_impl<3> + { + template< + typename R, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename Policy = empty_function_policy, + typename Mixin = empty_function_mixin, + typename Allocator = std::allocator + > + struct params + { + typedef function3 type; + }; + }; + + template<> + struct real_get_function_impl<4> + { + template< + typename R, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename Policy = empty_function_policy, + typename Mixin = empty_function_mixin, + typename Allocator = std::allocator + > + struct params + { + typedef function4 type; + }; + }; + + template<> + struct real_get_function_impl<5> + { + template< + typename R, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename Policy = empty_function_policy, + typename Mixin = empty_function_mixin, + typename Allocator = std::allocator + > + struct params + { + typedef function5 + type; + }; + }; + + template<> + struct real_get_function_impl<6> + { + template< + typename R, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename Policy = empty_function_policy, + typename Mixin = empty_function_mixin, + typename Allocator = std::allocator + > + struct params + { + typedef function6 + type; + }; + }; + + template<> + struct real_get_function_impl<7> + { + template< + typename R, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename Policy = empty_function_policy, + typename Mixin = empty_function_mixin, + typename Allocator = std::allocator + > + struct params + { + typedef function7 type; + }; + }; + + template<> + struct real_get_function_impl<8> + { + template< + typename R, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename Policy = empty_function_policy, + typename Mixin = empty_function_mixin, + typename Allocator = std::allocator + > + struct params + { + typedef function8 type; + }; + }; + + template<> + struct real_get_function_impl<9> + { + template< + typename R, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename Policy = empty_function_policy, + typename Mixin = empty_function_mixin, + typename Allocator = std::allocator + > + struct params + { + typedef function9 type; + }; + }; + + template<> + struct real_get_function_impl<10> + { + template< + typename R, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename Policy = empty_function_policy, + typename Mixin = empty_function_mixin, + typename Allocator = std::allocator + > + struct params + { + typedef function10 type; + }; + }; + + template< + typename R, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename Policy = empty_function_policy, + typename Mixin = empty_function_mixin, + typename Allocator = std::allocator + > + struct get_function_impl + { + typedef typename real_get_function_impl< + (count_used_args::value) + >::template params::type + type; + }; + + template< + typename R, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename MyPolicy = empty_function_policy, + typename MyMixin = empty_function_mixin, + typename MyAllocator = std::allocator + > + struct function_traits_builder + { + typedef typename get_function_impl::type + type; + + typedef MyPolicy policy_type; + typedef MyMixin mixin_type; + typedef MyAllocator allocator_type; + +#ifndef BOOST_NO_DEPENDENT_NESTED_DERIVATIONS + template + struct policy : + public function_traits_builder {}; + + template + struct mixin : + public function_traits_builder {}; + + template + struct allocator : + public function_traits_builder {}; +#else + template + struct policy + { + typedef typename function_traits_builder::type + type; + }; + + template + struct mixin + { + typedef typename function_traits_builder::type + type; + }; + + template + struct allocator + { + typedef typename function_traits_builder::type + type; + }; +#endif + }; + + } // end namespace function + } // end namespace detail + + template< + typename R, + typename T1 = detail::function::unusable, + typename T2 = detail::function::unusable, + typename T3 = detail::function::unusable, + typename T4 = detail::function::unusable, + typename T5 = detail::function::unusable, + typename T6 = detail::function::unusable, + typename T7 = detail::function::unusable, + typename T8 = detail::function::unusable, + typename T9 = detail::function::unusable, + typename T10 = detail::function::unusable + > + class function : + public detail::function::get_function_impl::type, + public detail::function::function_traits_builder + { + typedef typename detail::function::get_function_impl::type + base_type; + + public: + typedef typename base_type::policy_type policy_type; + typedef typename base_type::mixin_type mixin_type; + typedef typename base_type::allocator_type allocator_type; + typedef function self_type; + + function() : base_type() {} + + template + function(Functor BOOST_MSVC_INCLUDE(const &) f) : base_type(f) {} + + function(const function& f) : base_type(static_cast(f)){} + + function& operator=(const function& f) + { + const base_type& bf = static_cast(f); + base_type* self = this; + self->set(bf); + return *this; + } + + void set(const function& f) + { + const base_type& bf = static_cast(f); + base_type* self = this; + self->set(bf); + } + + void swap(function& other) + { +#ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + std::swap(this->manager, other.manager); + std::swap(this->functor, other.functor); + std::swap(this->invoker, other.invoker); +#else + std::swap(this->impl, other.impl); +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + +#ifdef BOOST_NO_DEPENDENT_BASE_LOOKUP + template + function& operator=(Functor BOOST_MSVC_INCLUDE(const &) f) + { + this->set(f); + return *this; + } + + base_type& operator=(const base_type& f) + { + this->set(f); + return *this; + } +#endif // BOOST_NO_DEPENDENT_BASE_LOOKUP + }; + + template + inline void swap(function& f1, + function& f2) + { + f1.swap(f2); + } +} + +#endif diff --git a/include/boost/function/function0.hpp b/include/boost/function/function0.hpp new file mode 100644 index 0000000..90b6212 --- /dev/null +++ b/include/boost/function/function0.hpp @@ -0,0 +1,55 @@ +// Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu) +// +// Permission to copy, use, sell and distribute this software is granted +// provided this copyright notice appears in all copies. +// Permission to modify the code and to distribute modified code is granted +// provided this copyright notice appears in all copies, and a notice +// that the code was modified is included with the copyright notice. +// +// This software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. + +// For more information, see http://www.boost.org + +#ifndef BOOST_FUNCTION0_HPP +#define BOOST_FUNCTION0_HPP + +#include + +#define BOOST_FUNCTION_NUM_ARGS 0 +#define BOOST_FUNCTION_COMMA +#define BOOST_FUNCTION_TEMPLATE_PARMS +#define BOOST_FUNCTION_TEMPLATE_ARGS +#define BOOST_FUNCTION_OTHER_TEMPLATE_PARMS +#define BOOST_FUNCTION_OTHER_TEMPLATE_ARGS +#define BOOST_FUNCTION_PARMS +#define BOOST_FUNCTION_ARGS +#define BOOST_FUNCTION_FUNCTION function0 +#define BOOST_FUNCTION_INVOKER_BASE invoker_base0 +#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker0 +#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker0 +#define BOOST_FUNCTION_FUNCTION_OBJ_INVOKER function_obj_invoker0 +#define BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER void_function_obj_invoker0 +#define BOOST_FUNCTION_GET_FUNCTION_INVOKER get_function_invoker0 +#define BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER get_function_obj_invoker0 + +#include + +#undef BOOST_FUNCTION_NUM_ARGS +#undef BOOST_FUNCTION_COMMA +#undef BOOST_FUNCTION_TEMPLATE_PARMS +#undef BOOST_FUNCTION_TEMPLATE_ARGS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_PARMS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_ARGS +#undef BOOST_FUNCTION_PARMS +#undef BOOST_FUNCTION_ARGS +#undef BOOST_FUNCTION_FUNCTION +#undef BOOST_FUNCTION_INVOKER_BASE +#undef BOOST_FUNCTION_FUNCTION_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER +#undef BOOST_FUNCTION_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER + +#endif // BOOST_FUNCTION0_HPP diff --git a/include/boost/function/function1.hpp b/include/boost/function/function1.hpp new file mode 100644 index 0000000..1ac0cd6 --- /dev/null +++ b/include/boost/function/function1.hpp @@ -0,0 +1,55 @@ +// Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu) +// +// Permission to copy, use, sell and distribute this software is granted +// provided this copyright notice appears in all copies. +// Permission to modify the code and to distribute modified code is granted +// provided this copyright notice appears in all copies, and a notice +// that the code was modified is included with the copyright notice. +// +// This software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. + +// For more information, see http://www.boost.org + +#ifndef BOOST_FUNCTION1_HPP +#define BOOST_FUNCTION1_HPP + +#include + +#define BOOST_FUNCTION_NUM_ARGS 1 +#define BOOST_FUNCTION_COMMA , +#define BOOST_FUNCTION_TEMPLATE_PARMS typename T1 +#define BOOST_FUNCTION_TEMPLATE_ARGS T1 +#define BOOST_FUNCTION_OTHER_TEMPLATE_PARMS typename OtherT1 +#define BOOST_FUNCTION_OTHER_TEMPLATE_ARGS OtherT1 +#define BOOST_FUNCTION_PARMS T1 a1 +#define BOOST_FUNCTION_ARGS a1 +#define BOOST_FUNCTION_FUNCTION function1 +#define BOOST_FUNCTION_INVOKER_BASE invoker_base1 +#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker1 +#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker1 +#define BOOST_FUNCTION_FUNCTION_OBJ_INVOKER function_obj_invoker1 +#define BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER void_function_obj_invoker1 +#define BOOST_FUNCTION_GET_FUNCTION_INVOKER get_function_invoker1 +#define BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER get_function_obj_invoker1 + +#include + +#undef BOOST_FUNCTION_NUM_ARGS +#undef BOOST_FUNCTION_COMMA +#undef BOOST_FUNCTION_TEMPLATE_PARMS +#undef BOOST_FUNCTION_TEMPLATE_ARGS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_PARMS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_ARGS +#undef BOOST_FUNCTION_PARMS +#undef BOOST_FUNCTION_ARGS +#undef BOOST_FUNCTION_FUNCTION +#undef BOOST_FUNCTION_INVOKER_BASE +#undef BOOST_FUNCTION_FUNCTION_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER +#undef BOOST_FUNCTION_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER + +#endif // BOOST_FUNCTION1_HPP diff --git a/include/boost/function/function10.hpp b/include/boost/function/function10.hpp new file mode 100644 index 0000000..1850b94 --- /dev/null +++ b/include/boost/function/function10.hpp @@ -0,0 +1,55 @@ +// Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu) +// +// Permission to copy, use, sell and distribute this software is granted +// provided this copyright notice appears in all copies. +// Permission to modify the code and to distribute modified code is granted +// provided this copyright notice appears in all copies, and a notice +// that the code was modified is included with the copyright notice. +// +// This software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. + +// For more information, see http://www.boost.org + +#ifndef BOOST_FUNCTION10_HPP +#define BOOST_FUNCTION10_HPP + +#include + +#define BOOST_FUNCTION_NUM_ARGS 10 +#define BOOST_FUNCTION_COMMA , +#define BOOST_FUNCTION_TEMPLATE_PARMS typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10 +#define BOOST_FUNCTION_TEMPLATE_ARGS T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 +#define BOOST_FUNCTION_OTHER_TEMPLATE_PARMS typename OtherT1, typename OtherT2, typename OtherT3, typename OtherT4, typename OtherT5, typename OtherT6, typename OtherT7, typename OtherT8, typename OtherT9, typename OtherT10 +#define BOOST_FUNCTION_OTHER_TEMPLATE_ARGS OtherT1, OtherT2, OtherT3, OtherT4, OtherT5, OtherT6, OtherT7, OtherT8, OtherT9, OtherT10 +#define BOOST_FUNCTION_PARMS T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, T8 a8, T9 a9, T10 a10 +#define BOOST_FUNCTION_ARGS a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 +#define BOOST_FUNCTION_FUNCTION function10 +#define BOOST_FUNCTION_INVOKER_BASE invoker_base10 +#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker10 +#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker10 +#define BOOST_FUNCTION_FUNCTION_OBJ_INVOKER function_obj_invoker10 +#define BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER void_function_obj_invoker10 +#define BOOST_FUNCTION_GET_FUNCTION_INVOKER get_function_invoker10 +#define BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER get_function_obj_invoker10 + +#include + +#undef BOOST_FUNCTION_NUM_ARGS +#undef BOOST_FUNCTION_COMMA +#undef BOOST_FUNCTION_TEMPLATE_PARMS +#undef BOOST_FUNCTION_TEMPLATE_ARGS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_PARMS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_ARGS +#undef BOOST_FUNCTION_PARMS +#undef BOOST_FUNCTION_ARGS +#undef BOOST_FUNCTION_FUNCTION +#undef BOOST_FUNCTION_INVOKER_BASE +#undef BOOST_FUNCTION_FUNCTION_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER +#undef BOOST_FUNCTION_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER + +#endif // BOOST_FUNCTION10_HPP diff --git a/include/boost/function/function2.hpp b/include/boost/function/function2.hpp new file mode 100644 index 0000000..1233f05 --- /dev/null +++ b/include/boost/function/function2.hpp @@ -0,0 +1,55 @@ +// Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu) +// +// Permission to copy, use, sell and distribute this software is granted +// provided this copyright notice appears in all copies. +// Permission to modify the code and to distribute modified code is granted +// provided this copyright notice appears in all copies, and a notice +// that the code was modified is included with the copyright notice. +// +// This software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. + +// For more information, see http://www.boost.org + +#ifndef BOOST_FUNCTION2_HPP +#define BOOST_FUNCTION2_HPP + +#include + +#define BOOST_FUNCTION_NUM_ARGS 2 +#define BOOST_FUNCTION_COMMA , +#define BOOST_FUNCTION_TEMPLATE_PARMS typename T1, typename T2 +#define BOOST_FUNCTION_TEMPLATE_ARGS T1, T2 +#define BOOST_FUNCTION_OTHER_TEMPLATE_PARMS typename OtherT1, typename OtherT2 +#define BOOST_FUNCTION_OTHER_TEMPLATE_ARGS OtherT1, OtherT2 +#define BOOST_FUNCTION_PARMS T1 a1, T2 a2 +#define BOOST_FUNCTION_ARGS a1, a2 +#define BOOST_FUNCTION_FUNCTION function2 +#define BOOST_FUNCTION_INVOKER_BASE invoker_base2 +#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker2 +#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker2 +#define BOOST_FUNCTION_FUNCTION_OBJ_INVOKER function_obj_invoker2 +#define BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER void_function_obj_invoker2 +#define BOOST_FUNCTION_GET_FUNCTION_INVOKER get_function_invoker2 +#define BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER get_function_obj_invoker2 + +#include + +#undef BOOST_FUNCTION_NUM_ARGS +#undef BOOST_FUNCTION_COMMA +#undef BOOST_FUNCTION_TEMPLATE_PARMS +#undef BOOST_FUNCTION_TEMPLATE_ARGS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_PARMS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_ARGS +#undef BOOST_FUNCTION_PARMS +#undef BOOST_FUNCTION_ARGS +#undef BOOST_FUNCTION_FUNCTION +#undef BOOST_FUNCTION_INVOKER_BASE +#undef BOOST_FUNCTION_FUNCTION_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER +#undef BOOST_FUNCTION_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER + +#endif // BOOST_FUNCTION2_HPP diff --git a/include/boost/function/function3.hpp b/include/boost/function/function3.hpp new file mode 100644 index 0000000..f1bf9b8 --- /dev/null +++ b/include/boost/function/function3.hpp @@ -0,0 +1,55 @@ +// Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu) +// +// Permission to copy, use, sell and distribute this software is granted +// provided this copyright notice appears in all copies. +// Permission to modify the code and to distribute modified code is granted +// provided this copyright notice appears in all copies, and a notice +// that the code was modified is included with the copyright notice. +// +// This software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. + +// For more information, see http://www.boost.org + +#ifndef BOOST_FUNCTION3_HPP +#define BOOST_FUNCTION3_HPP + +#include + +#define BOOST_FUNCTION_NUM_ARGS 3 +#define BOOST_FUNCTION_COMMA , +#define BOOST_FUNCTION_TEMPLATE_PARMS typename T1, typename T2, typename T3 +#define BOOST_FUNCTION_TEMPLATE_ARGS T1, T2, T3 +#define BOOST_FUNCTION_OTHER_TEMPLATE_PARMS typename OtherT1, typename OtherT2, typename OtherT3 +#define BOOST_FUNCTION_OTHER_TEMPLATE_ARGS OtherT1, OtherT2, OtherT3 +#define BOOST_FUNCTION_PARMS T1 a1, T2 a2, T3 a3 +#define BOOST_FUNCTION_ARGS a1, a2, a3 +#define BOOST_FUNCTION_FUNCTION function3 +#define BOOST_FUNCTION_INVOKER_BASE invoker_base3 +#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker3 +#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker3 +#define BOOST_FUNCTION_FUNCTION_OBJ_INVOKER function_obj_invoker3 +#define BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER void_function_obj_invoker3 +#define BOOST_FUNCTION_GET_FUNCTION_INVOKER get_function_invoker3 +#define BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER get_function_obj_invoker3 + +#include + +#undef BOOST_FUNCTION_NUM_ARGS +#undef BOOST_FUNCTION_COMMA +#undef BOOST_FUNCTION_TEMPLATE_PARMS +#undef BOOST_FUNCTION_TEMPLATE_ARGS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_PARMS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_ARGS +#undef BOOST_FUNCTION_PARMS +#undef BOOST_FUNCTION_ARGS +#undef BOOST_FUNCTION_FUNCTION +#undef BOOST_FUNCTION_INVOKER_BASE +#undef BOOST_FUNCTION_FUNCTION_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER +#undef BOOST_FUNCTION_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER + +#endif // BOOST_FUNCTION3_HPP diff --git a/include/boost/function/function4.hpp b/include/boost/function/function4.hpp new file mode 100644 index 0000000..525c9a3 --- /dev/null +++ b/include/boost/function/function4.hpp @@ -0,0 +1,55 @@ +// Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu) +// +// Permission to copy, use, sell and distribute this software is granted +// provided this copyright notice appears in all copies. +// Permission to modify the code and to distribute modified code is granted +// provided this copyright notice appears in all copies, and a notice +// that the code was modified is included with the copyright notice. +// +// This software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. + +// For more information, see http://www.boost.org + +#ifndef BOOST_FUNCTION4_HPP +#define BOOST_FUNCTION4_HPP + +#include + +#define BOOST_FUNCTION_NUM_ARGS 4 +#define BOOST_FUNCTION_COMMA , +#define BOOST_FUNCTION_TEMPLATE_PARMS typename T1, typename T2, typename T3, typename T4 +#define BOOST_FUNCTION_TEMPLATE_ARGS T1, T2, T3, T4 +#define BOOST_FUNCTION_OTHER_TEMPLATE_PARMS typename OtherT1, typename OtherT2, typename OtherT3, typename OtherT4 +#define BOOST_FUNCTION_OTHER_TEMPLATE_ARGS OtherT1, OtherT2, OtherT3, OtherT4 +#define BOOST_FUNCTION_PARMS T1 a1, T2 a2, T3 a3, T4 a4 +#define BOOST_FUNCTION_ARGS a1, a2, a3, a4 +#define BOOST_FUNCTION_FUNCTION function4 +#define BOOST_FUNCTION_INVOKER_BASE invoker_base4 +#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker4 +#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker4 +#define BOOST_FUNCTION_FUNCTION_OBJ_INVOKER function_obj_invoker4 +#define BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER void_function_obj_invoker4 +#define BOOST_FUNCTION_GET_FUNCTION_INVOKER get_function_invoker4 +#define BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER get_function_obj_invoker4 + +#include + +#undef BOOST_FUNCTION_NUM_ARGS +#undef BOOST_FUNCTION_COMMA +#undef BOOST_FUNCTION_TEMPLATE_PARMS +#undef BOOST_FUNCTION_TEMPLATE_ARGS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_PARMS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_ARGS +#undef BOOST_FUNCTION_PARMS +#undef BOOST_FUNCTION_ARGS +#undef BOOST_FUNCTION_FUNCTION +#undef BOOST_FUNCTION_INVOKER_BASE +#undef BOOST_FUNCTION_FUNCTION_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER +#undef BOOST_FUNCTION_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER + +#endif // BOOST_FUNCTION4_HPP diff --git a/include/boost/function/function5.hpp b/include/boost/function/function5.hpp new file mode 100644 index 0000000..abde1fd --- /dev/null +++ b/include/boost/function/function5.hpp @@ -0,0 +1,55 @@ +// Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu) +// +// Permission to copy, use, sell and distribute this software is granted +// provided this copyright notice appears in all copies. +// Permission to modify the code and to distribute modified code is granted +// provided this copyright notice appears in all copies, and a notice +// that the code was modified is included with the copyright notice. +// +// This software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. + +// For more information, see http://www.boost.org + +#ifndef BOOST_FUNCTION5_HPP +#define BOOST_FUNCTION5_HPP + +#include + +#define BOOST_FUNCTION_NUM_ARGS 5 +#define BOOST_FUNCTION_COMMA , +#define BOOST_FUNCTION_TEMPLATE_PARMS typename T1, typename T2, typename T3, typename T4, typename T5 +#define BOOST_FUNCTION_TEMPLATE_ARGS T1, T2, T3, T4, T5 +#define BOOST_FUNCTION_OTHER_TEMPLATE_PARMS typename OtherT1, typename OtherT2, typename OtherT3, typename OtherT4, typename OtherT5 +#define BOOST_FUNCTION_OTHER_TEMPLATE_ARGS OtherT1, OtherT2, OtherT3, OtherT4, OtherT5 +#define BOOST_FUNCTION_PARMS T1 a1, T2 a2, T3 a3, T4 a4, T5 a5 +#define BOOST_FUNCTION_ARGS a1, a2, a3, a4, a5 +#define BOOST_FUNCTION_FUNCTION function5 +#define BOOST_FUNCTION_INVOKER_BASE invoker_base5 +#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker5 +#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker5 +#define BOOST_FUNCTION_FUNCTION_OBJ_INVOKER function_obj_invoker5 +#define BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER void_function_obj_invoker5 +#define BOOST_FUNCTION_GET_FUNCTION_INVOKER get_function_invoker5 +#define BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER get_function_obj_invoker5 + +#include + +#undef BOOST_FUNCTION_NUM_ARGS +#undef BOOST_FUNCTION_COMMA +#undef BOOST_FUNCTION_TEMPLATE_PARMS +#undef BOOST_FUNCTION_TEMPLATE_ARGS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_PARMS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_ARGS +#undef BOOST_FUNCTION_PARMS +#undef BOOST_FUNCTION_ARGS +#undef BOOST_FUNCTION_FUNCTION +#undef BOOST_FUNCTION_INVOKER_BASE +#undef BOOST_FUNCTION_FUNCTION_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER +#undef BOOST_FUNCTION_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER + +#endif // BOOST_FUNCTION5_HPP diff --git a/include/boost/function/function6.hpp b/include/boost/function/function6.hpp new file mode 100644 index 0000000..86cabbc --- /dev/null +++ b/include/boost/function/function6.hpp @@ -0,0 +1,55 @@ +// Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu) +// +// Permission to copy, use, sell and distribute this software is granted +// provided this copyright notice appears in all copies. +// Permission to modify the code and to distribute modified code is granted +// provided this copyright notice appears in all copies, and a notice +// that the code was modified is included with the copyright notice. +// +// This software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. + +// For more information, see http://www.boost.org + +#ifndef BOOST_FUNCTION6_HPP +#define BOOST_FUNCTION6_HPP + +#include + +#define BOOST_FUNCTION_NUM_ARGS 6 +#define BOOST_FUNCTION_COMMA , +#define BOOST_FUNCTION_TEMPLATE_PARMS typename T1, typename T2, typename T3, typename T4, typename T5, typename T6 +#define BOOST_FUNCTION_TEMPLATE_ARGS T1, T2, T3, T4, T5, T6 +#define BOOST_FUNCTION_OTHER_TEMPLATE_PARMS typename OtherT1, typename OtherT2, typename OtherT3, typename OtherT4, typename OtherT5, typename OtherT6 +#define BOOST_FUNCTION_OTHER_TEMPLATE_ARGS OtherT1, OtherT2, OtherT3, OtherT4, OtherT5, OtherT6 +#define BOOST_FUNCTION_PARMS T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6 +#define BOOST_FUNCTION_ARGS a1, a2, a3, a4, a5, a6 +#define BOOST_FUNCTION_FUNCTION function6 +#define BOOST_FUNCTION_INVOKER_BASE invoker_base6 +#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker6 +#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker6 +#define BOOST_FUNCTION_FUNCTION_OBJ_INVOKER function_obj_invoker6 +#define BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER void_function_obj_invoker6 +#define BOOST_FUNCTION_GET_FUNCTION_INVOKER get_function_invoker6 +#define BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER get_function_obj_invoker6 + +#include + +#undef BOOST_FUNCTION_NUM_ARGS +#undef BOOST_FUNCTION_COMMA +#undef BOOST_FUNCTION_TEMPLATE_PARMS +#undef BOOST_FUNCTION_TEMPLATE_ARGS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_PARMS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_ARGS +#undef BOOST_FUNCTION_PARMS +#undef BOOST_FUNCTION_ARGS +#undef BOOST_FUNCTION_FUNCTION +#undef BOOST_FUNCTION_INVOKER_BASE +#undef BOOST_FUNCTION_FUNCTION_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER +#undef BOOST_FUNCTION_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER + +#endif // BOOST_FUNCTION6_HPP diff --git a/include/boost/function/function7.hpp b/include/boost/function/function7.hpp new file mode 100644 index 0000000..3ff508f --- /dev/null +++ b/include/boost/function/function7.hpp @@ -0,0 +1,55 @@ +// Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu) +// +// Permission to copy, use, sell and distribute this software is granted +// provided this copyright notice appears in all copies. +// Permission to modify the code and to distribute modified code is granted +// provided this copyright notice appears in all copies, and a notice +// that the code was modified is included with the copyright notice. +// +// This software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. + +// For more information, see http://www.boost.org + +#ifndef BOOST_FUNCTION7_HPP +#define BOOST_FUNCTION7_HPP + +#include + +#define BOOST_FUNCTION_NUM_ARGS 7 +#define BOOST_FUNCTION_COMMA , +#define BOOST_FUNCTION_TEMPLATE_PARMS typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7 +#define BOOST_FUNCTION_TEMPLATE_ARGS T1, T2, T3, T4, T5, T6, T7 +#define BOOST_FUNCTION_OTHER_TEMPLATE_PARMS typename OtherT1, typename OtherT2, typename OtherT3, typename OtherT4, typename OtherT5, typename OtherT6, typename OtherT7 +#define BOOST_FUNCTION_OTHER_TEMPLATE_ARGS OtherT1, OtherT2, OtherT3, OtherT4, OtherT5, OtherT6, OtherT7 +#define BOOST_FUNCTION_PARMS T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7 +#define BOOST_FUNCTION_ARGS a1, a2, a3, a4, a5, a6, a7 +#define BOOST_FUNCTION_FUNCTION function7 +#define BOOST_FUNCTION_INVOKER_BASE invoker_base7 +#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker7 +#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker7 +#define BOOST_FUNCTION_FUNCTION_OBJ_INVOKER function_obj_invoker7 +#define BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER void_function_obj_invoker7 +#define BOOST_FUNCTION_GET_FUNCTION_INVOKER get_function_invoker7 +#define BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER get_function_obj_invoker7 + +#include + +#undef BOOST_FUNCTION_NUM_ARGS +#undef BOOST_FUNCTION_COMMA +#undef BOOST_FUNCTION_TEMPLATE_PARMS +#undef BOOST_FUNCTION_TEMPLATE_ARGS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_PARMS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_ARGS +#undef BOOST_FUNCTION_PARMS +#undef BOOST_FUNCTION_ARGS +#undef BOOST_FUNCTION_FUNCTION +#undef BOOST_FUNCTION_INVOKER_BASE +#undef BOOST_FUNCTION_FUNCTION_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER +#undef BOOST_FUNCTION_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER + +#endif // BOOST_FUNCTION7_HPP diff --git a/include/boost/function/function8.hpp b/include/boost/function/function8.hpp new file mode 100644 index 0000000..4f536c4 --- /dev/null +++ b/include/boost/function/function8.hpp @@ -0,0 +1,55 @@ +// Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu) +// +// Permission to copy, use, sell and distribute this software is granted +// provided this copyright notice appears in all copies. +// Permission to modify the code and to distribute modified code is granted +// provided this copyright notice appears in all copies, and a notice +// that the code was modified is included with the copyright notice. +// +// This software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. + +// For more information, see http://www.boost.org + +#ifndef BOOST_FUNCTION8_HPP +#define BOOST_FUNCTION8_HPP + +#include + +#define BOOST_FUNCTION_NUM_ARGS 8 +#define BOOST_FUNCTION_COMMA , +#define BOOST_FUNCTION_TEMPLATE_PARMS typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8 +#define BOOST_FUNCTION_TEMPLATE_ARGS T1, T2, T3, T4, T5, T6, T7, T8 +#define BOOST_FUNCTION_OTHER_TEMPLATE_PARMS typename OtherT1, typename OtherT2, typename OtherT3, typename OtherT4, typename OtherT5, typename OtherT6, typename OtherT7, typename OtherT8 +#define BOOST_FUNCTION_OTHER_TEMPLATE_ARGS OtherT1, OtherT2, OtherT3, OtherT4, OtherT5, OtherT6, OtherT7, OtherT8 +#define BOOST_FUNCTION_PARMS T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, T8 a8 +#define BOOST_FUNCTION_ARGS a1, a2, a3, a4, a5, a6, a7, a8 +#define BOOST_FUNCTION_FUNCTION function8 +#define BOOST_FUNCTION_INVOKER_BASE invoker_base8 +#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker8 +#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker8 +#define BOOST_FUNCTION_FUNCTION_OBJ_INVOKER function_obj_invoker8 +#define BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER void_function_obj_invoker8 +#define BOOST_FUNCTION_GET_FUNCTION_INVOKER get_function_invoker8 +#define BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER get_function_obj_invoker8 + +#include + +#undef BOOST_FUNCTION_NUM_ARGS +#undef BOOST_FUNCTION_COMMA +#undef BOOST_FUNCTION_TEMPLATE_PARMS +#undef BOOST_FUNCTION_TEMPLATE_ARGS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_PARMS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_ARGS +#undef BOOST_FUNCTION_PARMS +#undef BOOST_FUNCTION_ARGS +#undef BOOST_FUNCTION_FUNCTION +#undef BOOST_FUNCTION_INVOKER_BASE +#undef BOOST_FUNCTION_FUNCTION_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER +#undef BOOST_FUNCTION_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER + +#endif // BOOST_FUNCTION8_HPP diff --git a/include/boost/function/function9.hpp b/include/boost/function/function9.hpp new file mode 100644 index 0000000..84864ec --- /dev/null +++ b/include/boost/function/function9.hpp @@ -0,0 +1,55 @@ +// Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu) +// +// Permission to copy, use, sell and distribute this software is granted +// provided this copyright notice appears in all copies. +// Permission to modify the code and to distribute modified code is granted +// provided this copyright notice appears in all copies, and a notice +// that the code was modified is included with the copyright notice. +// +// This software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. + +// For more information, see http://www.boost.org + +#ifndef BOOST_FUNCTION9_HPP +#define BOOST_FUNCTION9_HPP + +#include + +#define BOOST_FUNCTION_NUM_ARGS 9 +#define BOOST_FUNCTION_COMMA , +#define BOOST_FUNCTION_TEMPLATE_PARMS typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9 +#define BOOST_FUNCTION_TEMPLATE_ARGS T1, T2, T3, T4, T5, T6, T7, T8, T9 +#define BOOST_FUNCTION_OTHER_TEMPLATE_PARMS typename OtherT1, typename OtherT2, typename OtherT3, typename OtherT4, typename OtherT5, typename OtherT6, typename OtherT7, typename OtherT8, typename OtherT9 +#define BOOST_FUNCTION_OTHER_TEMPLATE_ARGS OtherT1, OtherT2, OtherT3, OtherT4, OtherT5, OtherT6, OtherT7, OtherT8, OtherT9 +#define BOOST_FUNCTION_PARMS T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, T8 a8, T9 a9 +#define BOOST_FUNCTION_ARGS a1, a2, a3, a4, a5, a6, a7, a8, a9 +#define BOOST_FUNCTION_FUNCTION function9 +#define BOOST_FUNCTION_INVOKER_BASE invoker_base9 +#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker9 +#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker9 +#define BOOST_FUNCTION_FUNCTION_OBJ_INVOKER function_obj_invoker9 +#define BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER void_function_obj_invoker9 +#define BOOST_FUNCTION_GET_FUNCTION_INVOKER get_function_invoker9 +#define BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER get_function_obj_invoker9 + +#include + +#undef BOOST_FUNCTION_NUM_ARGS +#undef BOOST_FUNCTION_COMMA +#undef BOOST_FUNCTION_TEMPLATE_PARMS +#undef BOOST_FUNCTION_TEMPLATE_ARGS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_PARMS +#undef BOOST_FUNCTION_OTHER_TEMPLATE_ARGS +#undef BOOST_FUNCTION_PARMS +#undef BOOST_FUNCTION_ARGS +#undef BOOST_FUNCTION_FUNCTION +#undef BOOST_FUNCTION_INVOKER_BASE +#undef BOOST_FUNCTION_FUNCTION_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER +#undef BOOST_FUNCTION_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_INVOKER +#undef BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER + +#endif // BOOST_FUNCTION9_HPP diff --git a/include/boost/function/function_base.hpp b/include/boost/function/function_base.hpp new file mode 100644 index 0000000..ee5ef5f --- /dev/null +++ b/include/boost/function/function_base.hpp @@ -0,0 +1,416 @@ +// Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu) +// +// Permission to copy, use, sell and distribute this software is granted +// provided this copyright notice appears in all copies. +// Permission to modify the code and to distribute modified code is granted +// provided this copyright notice appears in all copies, and a notice +// that the code was modified is included with the copyright notice. +// +// This software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. + +// For more information, see http://www.boost.org + +#ifndef BOOST_FUNCTION_BASE_HEADER +#define BOOST_FUNCTION_BASE_HEADER + +#include +#include +#include +#include +#include + +// Microsoft Visual C++ 6.0sp5 has lots of quirks +#ifdef BOOST_MSVC +# define BOOST_MSVC_INCLUDE(x) x +#else +# define BOOST_MSVC_INCLUDE(x) +#endif + +namespace boost { + namespace detail { + namespace function { + /* + * The IF implementation is temporary code. When a Boost metaprogramming + * library is introduced, Boost.Function will use it instead. + */ + namespace intimate { + struct SelectThen + { + template + struct Result + { + typedef Then RET; + }; + }; + + struct SelectElse + { + template + struct Result + { + typedef Else RET; + }; + }; + + template + struct Selector + { + typedef SelectThen RET; + }; + + template<> + struct Selector + { + typedef SelectElse RET; + }; + } // end namespace intimate + + template + struct IF + { + typedef typename intimate::Selector::RET select; + typedef typename select::template Result::RET RET; + typedef RET type; + }; + + /** + * A union of a function pointer and a void pointer. This is necessary + * because 5.2.10/6 allows reinterpret_cast<> to safely cast between + * function pointer types and 5.2.9/10 allows static_cast<> to safely + * cast between a void pointer and an object pointer. But it is not legal + * to cast between a function pointer and a void* (in either direction), + * so function requires a union of the two. */ + union any_pointer + { + void* obj_ptr; + void (*func_ptr)(); + + explicit any_pointer(void* p) : obj_ptr(p) {} + explicit any_pointer(void (*p)()) : func_ptr(p) {} + }; + + /** + * The unusable class is a placeholder for unused function arguments + * It is also completely unusable except that it constructable from + * anything. This helps compilers without partial specialization to + * handle Boost.Function objects returning void. + */ + struct unusable + { + unusable() {} + template unusable(const T&) {} + }; + + /* Determine the return type. This supports compilers that do not support + * void returns or partial specialization by silently changing the return + * type to "unusable". + */ + template struct function_return_type { typedef T type; }; + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template<> + struct function_return_type + { + typedef unusable type; + }; +#endif /* BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION */ + + // The operation type to perform on the given functor/function pointer + enum functor_manager_operation_type { clone_functor, destroy_functor }; + + // Tags used to decide between function and function object pointers. + struct function_ptr_tag {}; + struct function_obj_tag {}; + +#ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + /** + * The functor_manager class contains a static function "manage" which + * can clone or destroy the given function/function object pointer. + */ + template + struct functor_manager + { + private: + typedef Functor functor_type; +# ifndef BOOST_NO_STD_ALLOCATOR + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; +# else + typedef functor_type* pointer_type; +# endif // BOOST_NO_STD_ALLOCATOR + + // For function pointers, the manager is trivial + static inline any_pointer + manager(any_pointer function_ptr, functor_manager_operation_type op, + function_ptr_tag) + { + if (op == clone_functor) + return function_ptr; + else + return any_pointer(static_cast(0)); + } + + // For function object pointers, we clone the pointer to each + // function has its own version. + static inline any_pointer + manager(any_pointer function_obj_ptr, + functor_manager_operation_type op, + function_obj_tag) + { +# ifndef BOOST_NO_STD_ALLOCATOR + allocator_type allocator; +# endif // BOOST_NO_STD_ALLOCATOR + + if (op == clone_functor) { + functor_type* f = + static_cast(function_obj_ptr.obj_ptr); + + // Clone the functor +# ifndef BOOST_NO_STD_ALLOCATOR + pointer_type copy = allocator.allocate(1); + allocator.construct(copy, *f); + + // Get back to the original pointer type + functor_type* new_f = static_cast(copy); +# else + functor_type* new_f = new functor_type(*f); +# endif // BOOST_NO_STD_ALLOCATOR + return any_pointer(static_cast(new_f)); + } + else { + /* Cast from the void pointer to the functor pointer type */ + functor_type* f = + reinterpret_cast(function_obj_ptr.obj_ptr); + +# ifndef BOOST_NO_STD_ALLOCATOR + /* Cast from the functor pointer type to the allocator's pointer + type */ + pointer_type victim = static_cast(f); + + + // Destroy and deallocate the functor + allocator.destroy(victim); + allocator.deallocate(victim, 1); +# else + delete f; +# endif // BOOST_NO_STD_ALLOCATOR + + return any_pointer(static_cast(0)); + } + } + + public: + /* Dispatch to an appropriate manager based on whether we have a + function pointer or a function object pointer. */ + static any_pointer + manage(any_pointer functor_ptr, functor_manager_operation_type op) + { + typedef typename IF<(is_pointer::value), + function_ptr_tag, + function_obj_tag>::RET tag_type; + + return manager(functor_ptr, op, tag_type()); + } + }; +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + + // value=1 if the given type is not "unusable" + template + struct count_if_used + { + BOOST_STATIC_CONSTANT(int, value = 1); + }; + + // value=0 for unusable types + template<> + struct count_if_used + { + BOOST_STATIC_CONSTANT(int, value = 0); + }; + + // Count the number of arguments (from the given set) which are not + // "unusable" (therefore, count those arguments that are used). + template + struct count_used_args + { + BOOST_STATIC_CONSTANT(int, value = + (count_if_used::value + + count_if_used::value + + count_if_used::value + + count_if_used::value + + count_if_used::value + + count_if_used::value + + count_if_used::value + + count_if_used::value + + count_if_used::value + + count_if_used::value)); + }; + } // end namespace function + } // end namespace detail + + /** + * The function_base class contains the basic elements needed for the + * function1, function2, function3, etc. classes. It is common to all + * functions (and as such can be used to tell if we have one of the + * functionN objects). + */ + class function_base + { +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + public: + function_base() : impl(0) {} + + bool empty() const { return impl == 0; } + + + protected: + void* impl; // Derived class is responsible for knowing the real type +#else + public: + function_base() : manager(0), functor(static_cast(0)) {} + + // Is this function empty? + bool empty() const { return !manager; } + + protected: + detail::function::any_pointer (*manager)( + detail::function::any_pointer, + detail::function::functor_manager_operation_type); + detail::function::any_pointer functor; +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + +#ifndef BOOST_WEAK_CONVERSION_OPERATORS + private: + struct dummy { + void nonnull() {}; + }; + + typedef void (dummy::*safe_bool)(); + public: + operator safe_bool () const + { + return (this->empty())? 0 : &dummy::nonnull; + } +#else + public: + operator bool() const { return !this->empty(); } +#endif // BOOST_WEAK_CONVERSION_OPERATORS + }; + + /* Poison comparison between Boost.Function objects (because it is + * meaningless). The comparisons would otherwise be allowed because of the + * conversion required to allow syntax such as: + * boost::function f; + * if (f) { f(5); } + */ + void operator==(const function_base&, const function_base&); + void operator!=(const function_base&, const function_base&); + + namespace detail { + namespace function { + /** + * Determine if the given target is empty. + */ + + // Fallback - assume target is not empty + inline bool has_empty_target(...) + { + return false; + } + + // If the target is a 'function', query the empty() method + inline bool has_empty_target(const function_base* af) + { + return af->empty(); + } + + // If the target is a 'function', query the empty() method + inline bool has_empty_target(const function_base& af) + { + return af.empty(); + } + + // A function pointer is empty if it is null + template + inline bool has_empty_target(R (*f)()) + { + return f == 0; + } + + template + inline bool has_empty_target(R (*f)(T1)) + { + return f == 0; + } + + template + inline bool has_empty_target(R (*f)(T1, T2)) + { + return f == 0; + } + + template + inline bool has_empty_target(R (*f)(T1, T2, T3)) + { + return f == 0; + } + + template + inline bool has_empty_target(R (*f)(T1, T2, T3, T4)) + { + return f == 0; + } + + template + inline bool has_empty_target(R (*f)(T1, T2, T3, T4, T5)) + { + return f == 0; + } + + template + inline bool has_empty_target(R (*f)(T1, T2, T3, T4, T5, T6)) + { + return f == 0; + } + + template + inline bool has_empty_target(R (*f)(T1, T2, T3, T4, T5, T6, T7)) + { + return f == 0; + } + + template + inline bool has_empty_target(R (*f)(T1, T2, T3, T4, T5, T6, T7, T8)) + { + return f == 0; + } + + template + inline bool has_empty_target(R (*f)(T1, T2, T3, T4, T5, T6, T7, T8, T9)) + { + return f == 0; + } + } // end namespace function + } // end namespace detail + + // The default function policy is to do nothing before and after the call. + struct empty_function_policy + { + inline void precall(const function_base*) {} + inline void postcall(const function_base*) {} + }; + + // The default function mixin costs nothing + struct empty_function_mixin {}; +} + +#endif // BOOST_FUNCTION_BASE_HEADER diff --git a/include/boost/function/function_template.hpp b/include/boost/function/function_template.hpp new file mode 100644 index 0000000..842761f --- /dev/null +++ b/include/boost/function/function_template.hpp @@ -0,0 +1,1808 @@ +// Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu) +// +// Permission to copy, use, sell and distribute this software is granted +// provided this copyright notice appears in all copies. +// Permission to modify the code and to distribute modified code is granted +// provided this copyright notice appears in all copies, and a notice +// that the code was modified is included with the copyright notice. +// +// This software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. + +// For more information, see http://www.boost.org + +/* Note: this header is a header template and must NOT have multiple-inclusion + protection. */ + +#include +#include + +namespace boost { + namespace detail { + namespace function { +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + template + struct BOOST_FUNCTION_INVOKER_BASE + { + virtual ~BOOST_FUNCTION_INVOKER_BASE() {} + virtual R call(BOOST_FUNCTION_PARMS) = 0; + virtual R call(BOOST_FUNCTION_PARMS) const = 0; + virtual BOOST_FUNCTION_INVOKER_BASE* clone() const = 0; + virtual void destroy(BOOST_FUNCTION_INVOKER_BASE*) = 0; + }; +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + + template< + typename FunctionPtr, +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + typename Allocator, +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + typename R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_PARMS + > + struct BOOST_FUNCTION_FUNCTION_INVOKER +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + : public BOOST_FUNCTION_INVOKER_BASE< + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + > +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + { +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + explicit BOOST_FUNCTION_FUNCTION_INVOKER(FunctionPtr f) : + function_ptr(f) {} + + virtual R call(BOOST_FUNCTION_PARMS) + { + return function_ptr(BOOST_FUNCTION_ARGS); + } + + virtual R call(BOOST_FUNCTION_PARMS) const + { + return function_ptr(BOOST_FUNCTION_ARGS); + } + + virtual BOOST_FUNCTION_FUNCTION_INVOKER* clone() const + { +# ifdef BOOST_NO_STD_ALLOCATOR + return new BOOST_FUNCTION_FUNCTION_INVOKER(function_ptr); +# else + typedef typename Allocator:: + template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + allocator.construct(copy, *this); + return static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + } + + virtual void destroy(BOOST_FUNCTION_INVOKER_BASE< + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >* p) + { +# ifdef BOOST_NO_STD_ALLOCATOR + delete p; +# else + BOOST_FUNCTION_FUNCTION_INVOKER* victim = + dynamic_cast(p); + + typedef typename Allocator:: + template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + allocator.destroy(victim); + allocator.deallocate(victim, 1); +# endif // BOOST_NO_STD_ALLOCATOR + } + + private: + FunctionPtr function_ptr; +#else + static R invoke(any_pointer function_ptr, + bool BOOST_FUNCTION_COMMA + BOOST_FUNCTION_PARMS) + { + FunctionPtr f = reinterpret_cast(function_ptr.func_ptr); + return f(BOOST_FUNCTION_ARGS); + } +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + }; + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template< + typename FunctionPtr, +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + typename Allocator, +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + typename R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_PARMS + > + struct BOOST_FUNCTION_VOID_FUNCTION_INVOKER +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + : public BOOST_FUNCTION_INVOKER_BASE< + unusable BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + > +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + { +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + explicit BOOST_FUNCTION_VOID_FUNCTION_INVOKER(FunctionPtr f) : + function_ptr(f) {} + + virtual unusable call(BOOST_FUNCTION_PARMS) + { + function_ptr(BOOST_FUNCTION_ARGS); + return unusable(); + } + + virtual unusable call(BOOST_FUNCTION_PARMS) const + { + function_ptr(BOOST_FUNCTION_ARGS); + return unusable; + } + + virtual BOOST_FUNCTION_VOID_FUNCTION_INVOKER* clone() const + { +# ifdef BOOST_NO_STD_ALLOCATOR + return new BOOST_FUNCTION_VOID_FUNCTION_INVOKER(function_ptr); +# else + typedef typename Allocator:: + template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + allocator.construct(copy, *this); + return static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + } + + virtual void destroy(BOOST_FUNCTION_INVOKER_BASE< + unusable BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >* p) + { +# ifdef BOOST_NO_STD_ALLOCATOR + delete p; +# else + BOOST_FUNCTION_VOID_FUNCTION_INVOKER* victim = + dynamic_cast(p); + + typedef typename Allocator:: + template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + allocator.destroy(victim); + allocator.deallocate(victim, 1); +# endif // BOOST_NO_STD_ALLOCATOR + } + + private: + FunctionPtr function_ptr; +# else + static unusable invoke(any_pointer function_ptr, + bool BOOST_FUNCTION_COMMA + BOOST_FUNCTION_PARMS) + + { + FunctionPtr f = reinterpret_cast(function_ptr.func_ptr); + f(BOOST_FUNCTION_ARGS); + return unusable(); + } +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + }; + +#else + template< + typename FunctionPtr, +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + typename Allocator, +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + typename R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_PARMS + > + struct BOOST_FUNCTION_VOID_FUNCTION_INVOKER +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + : public BOOST_FUNCTION_INVOKER_BASE< + void BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + > +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + { +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + explicit BOOST_FUNCTION_VOID_FUNCTION_INVOKER(FunctionPtr f) : + function_ptr(f) {} + + virtual void call(BOOST_FUNCTION_PARMS) + { + function_ptr(BOOST_FUNCTION_ARGS); + } + + virtual void call(BOOST_FUNCTION_PARMS) const + { + function_ptr(BOOST_FUNCTION_ARGS); + } + + virtual BOOST_FUNCTION_VOID_FUNCTION_INVOKER* clone() const + { +# ifdef BOOST_NO_STD_ALLOCATOR + return new BOOST_FUNCTION_VOID_FUNCTION_INVOKER(function_ptr); +# else + typedef typename Allocator:: + template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + allocator.construct(copy, *this); + return static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + } + + virtual void destroy(BOOST_FUNCTION_INVOKER_BASE< + void BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >* p) + { +# ifdef BOOST_NO_STD_ALLOCATOR + delete p; +# else + BOOST_FUNCTION_VOID_FUNCTION_INVOKER* victim = + dynamic_cast(p); + + typedef typename Allocator:: + template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + allocator.destroy(victim); + allocator.deallocate(victim, 1); +# endif // BOOST_NO_STD_ALLOCATOR + } + + private: + FunctionPtr function_ptr; +# else + static void invoke(any_pointer function_ptr, + bool BOOST_FUNCTION_COMMA + BOOST_FUNCTION_PARMS) + { + FunctionPtr f = reinterpret_cast(function_ptr.func_ptr); + f(BOOST_FUNCTION_ARGS); + } +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + }; + +#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + template< + typename FunctionObj, +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + typename Allocator, +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + typename R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_PARMS + > + struct BOOST_FUNCTION_FUNCTION_OBJ_INVOKER +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + : public BOOST_FUNCTION_INVOKER_BASE< + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + > +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + { +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + explicit BOOST_FUNCTION_FUNCTION_OBJ_INVOKER(const FunctionObj& f) : + function_obj(f) {} + + virtual R call(BOOST_FUNCTION_PARMS) + { + return function_obj(BOOST_FUNCTION_ARGS); + } + + virtual R call(BOOST_FUNCTION_PARMS) const + { + return function_obj(BOOST_FUNCTION_ARGS); + } + + virtual BOOST_FUNCTION_FUNCTION_OBJ_INVOKER* clone() const + { +#ifdef BOOST_NO_STD_ALLOCATOR + return new BOOST_FUNCTION_FUNCTION_OBJ_INVOKER(function_obj); +#else + typedef typename Allocator:: + template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + allocator.construct(copy, *this); + return static_cast(copy); +#endif // BOOST_NO_STD_ALLOCATOR + } + + virtual void destroy(BOOST_FUNCTION_INVOKER_BASE< + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >* p) + { +#ifdef BOOST_NO_STD_ALLOCATOR + delete p; +#else + BOOST_FUNCTION_FUNCTION_OBJ_INVOKER* victim = + dynamic_cast(p); + + typedef typename Allocator:: + template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + allocator.destroy(victim); + allocator.deallocate(victim, 1); +#endif // BOOST_NO_STD_ALLOCATOR + } + + private: + FunctionObj function_obj; +#else + static R invoke(any_pointer function_obj_ptr, + bool is_const BOOST_FUNCTION_COMMA + BOOST_FUNCTION_PARMS) + + { + FunctionObj* f = static_cast(function_obj_ptr.obj_ptr); + if (is_const) { + const FunctionObj* fc = f; + return (*fc)(BOOST_FUNCTION_ARGS); + } + else { + return (*f)(BOOST_FUNCTION_ARGS); + } + } +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + }; + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template< + typename FunctionObj, +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + typename Allocator, +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + typename R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_PARMS + > + struct BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + : public BOOST_FUNCTION_INVOKER_BASE< + unusable BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + > +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + { +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + explicit BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER(const FunctionObj& f) + : function_obj(f) {} + + virtual unusable call(BOOST_FUNCTION_PARMS) + { + function_obj(BOOST_FUNCTION_ARGS); + return unusable(); + } + + virtual unusable call(BOOST_FUNCTION_PARMS) const + { + function_obj(BOOST_FUNCTION_ARGS); + return unusable(); + } + + virtual BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER* clone() const + { +#ifdef BOOST_NO_STD_ALLOCATOR + return new BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER(function_obj); +#else + typedef typename Allocator:: + template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + allocator.construct(copy, *this); + return static_cast(copy); +#endif // BOOST_NO_STD_ALLOCATOR + } + + virtual void destroy(BOOST_FUNCTION_INVOKER_BASE< + unusable BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >* p) + { +#ifdef BOOST_NO_STD_ALLOCATOR + delete p; +#else + BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER* victim = + dynamic_cast(p); + + typedef typename Allocator:: + template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + allocator.destroy(victim); + allocator.deallocate(victim, 1); +#endif // BOOST_NO_STD_ALLOCATOR + } + + private: + FunctionObj function_obj; +# else + static unusable invoke(any_pointer function_obj_ptr, + bool is_const BOOST_FUNCTION_COMMA + BOOST_FUNCTION_PARMS) + + { + FunctionObj* f = static_cast(function_obj_ptr.obj_ptr); + if (is_const) { + const FunctionObj* fc = f; + (*fc)(BOOST_FUNCTION_ARGS); + } + else { + (*f)(BOOST_FUNCTION_ARGS); + } + + return unusable(); + } +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + }; +#else + template< + typename FunctionObj, +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + typename Allocator, +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + typename R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_PARMS + > + struct BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + : public BOOST_FUNCTION_INVOKER_BASE< + void BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + > +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + { +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + explicit BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER(const FunctionObj& f) + : function_obj(f) {} + + virtual void call(BOOST_FUNCTION_PARMS) + { + function_obj(BOOST_FUNCTION_ARGS); + } + + virtual void call(BOOST_FUNCTION_PARMS) const + { + function_obj(BOOST_FUNCTION_ARGS); + } + + virtual BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER * clone() const + { +# ifdef BOOST_NO_STD_ALLOCATOR + return new BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER (function_obj); +# else + typedef typename Allocator:: + template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + allocator.construct(copy, *this); + return static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + } + + virtual void destroy(BOOST_FUNCTION_INVOKER_BASE< + void BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >* p) + { +#ifdef BOOST_NO_STD_ALLOCATOR + delete p; +#else + BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER* victim = + dynamic_cast(p); + + typedef typename Allocator:: + template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + allocator.destroy(victim); + allocator.deallocate(victim, 1); +#endif // BOOST_NO_STD_ALLOCATOR + } + + private: + FunctionObj function_obj; +# else + static void + invoke(any_pointer function_obj_ptr, + bool is_const BOOST_FUNCTION_COMMA + BOOST_FUNCTION_PARMS) + + { + FunctionObj* f = static_cast(function_obj_ptr.obj_ptr); + if (is_const) { + const FunctionObj* fc = f; + (*fc)(BOOST_FUNCTION_ARGS); + } + else { + (*f)(BOOST_FUNCTION_ARGS); + } + } +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + }; +#endif + + template< + typename FunctionPtr, + typename Allocator, + typename R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_PARMS + > + struct BOOST_FUNCTION_GET_FUNCTION_INVOKER + { + typedef typename IF<(is_void::value), + BOOST_FUNCTION_VOID_FUNCTION_INVOKER< + FunctionPtr, +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + Allocator, +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >, + BOOST_FUNCTION_FUNCTION_INVOKER< + FunctionPtr, +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + Allocator, +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + > + >::type type; + }; + + template< + typename FunctionObj, + typename Allocator, + typename R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_PARMS + > + struct BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER + { + typedef typename IF<(is_void::value), + BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER< + FunctionObj, +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + Allocator, +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >, + BOOST_FUNCTION_FUNCTION_OBJ_INVOKER< + FunctionObj, +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + Allocator, +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + > + >::type type; + }; + } // end namespace function + } // end namespace detail + + template< + typename R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_PARMS, + typename Policy = empty_function_policy, + typename Mixin = empty_function_mixin, + typename Allocator = std::allocator + > + class BOOST_FUNCTION_FUNCTION : public function_base, public Mixin + { + public: + BOOST_STATIC_CONSTANT(int, args = BOOST_FUNCTION_NUM_ARGS); + + typedef typename detail::function::function_return_type::type + result_type; + typedef Policy policy_type; + typedef Mixin mixin_type; + typedef Allocator allocator_type; + +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + private: + typedef detail::function::BOOST_FUNCTION_INVOKER_BASE< + result_type BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + > + impl_type; + + public: +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + + +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + // Construct without a target + BOOST_FUNCTION_FUNCTION() : function_base() {} +#else + // Construct without a target + BOOST_FUNCTION_FUNCTION() : function_base() +# ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + , invoker(0) +# endif + { + } + +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + +#ifdef BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING + // Clone the functor target f and make the clone the target + template + BOOST_FUNCTION_FUNCTION(Functor BOOST_MSVC_INCLUDE(const &) f) : + function_base() +# ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + , invoker(0) +# endif + { + if (!detail::function::has_empty_target(f)) + assign_to(f); + } +#else + template + BOOST_FUNCTION_FUNCTION(const Functor& f) : function_base() +# ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + , invoker(0) +# endif + { + if (!detail::function::has_empty_target(&f)) { + typedef + typename detail::function::BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER< + Functor, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >::type + invoker_type; + +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS +# ifdef BOOST_NO_STD_ALLOCATOR + impl_type* i = new invoker_type(f); +# else + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + new (copy) invoker_type(f); + impl_type* i = static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + impl = static_cast(i); +# else + invoker = &invoker_type::invoke; + manager = &detail::function::functor_manager::manage; + functor = manager(detail::function::any_pointer(const_cast(&f)), + detail::function::clone_functor); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + } + + template + BOOST_FUNCTION_FUNCTION(OtherR (*f)( + BOOST_FUNCTION_OTHER_TEMPLATE_ARGS + )) : function_base() +# ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + , invoker(0) +# endif + { + if (f) { + typedef OtherR (*FunctionPtr)(BOOST_FUNCTION_OTHER_TEMPLATE_ARGS); + typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_INVOKER< + FunctionPtr, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >::type + invoker_type; + +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS +# ifdef BOOST_NO_STD_ALLOCATOR + impl_type* i = new invoker_type(f); +# else + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + new (copy) invoker_type(f); + impl_type* i = static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + impl = static_cast(i); +# else + invoker = &invoker_type::invoke; + manager = &detail::function::functor_manager + ::manage; + functor = manager(detail::function::any_pointer(reinterpret_cast(f)), + detail::function::clone_functor); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + } +#endif // BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING + + // Clone the input BOOST_FUNCTION_FUNCTION's target + BOOST_FUNCTION_FUNCTION(const BOOST_FUNCTION_FUNCTION& f): function_base() +# ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + , invoker(0) +# endif + { + if (!f.empty()) { +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + impl_type* other_impl = reinterpret_cast(f.impl); + impl = static_cast(other_impl->clone()); +# else + invoker = f.invoker; + manager = f.manager; + functor = f.manager(f.functor, detail::function::clone_functor); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + } + + // Destroy the target, if there is one + ~BOOST_FUNCTION_FUNCTION() { clear(); } + + void swap(BOOST_FUNCTION_FUNCTION& other) + { +#ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + std::swap(manager, other.manager); + std::swap(functor, other.functor); + std::swap(invoker, other.invoker); +#else + std::swap(impl, other.impl); +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + + // Invoke the target + result_type operator()(BOOST_FUNCTION_PARMS) + { + assert(!this->empty()); + + policy_type policy; + policy.precall(this); + +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + impl_type* i = reinterpret_cast(impl); + result_type result = i->call(BOOST_FUNCTION_ARGS); +#else + result_type result = invoker(functor, + false BOOST_FUNCTION_COMMA + BOOST_FUNCTION_ARGS); +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + + policy.postcall(this); + return result; + } + + result_type operator()(BOOST_FUNCTION_PARMS) const + { + assert(!this->empty()); + + policy_type policy; + policy.precall(this); + +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + const impl_type* i = reinterpret_cast(impl); + result_type result = i->call(BOOST_FUNCTION_ARGS); +#else + result_type result = invoker(functor, + true BOOST_FUNCTION_COMMA + BOOST_FUNCTION_ARGS); +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + + policy.postcall(this); + return result; + } + + // Clear out a target, if there is one + void clear() + { +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + if (impl) { + impl_type* i = reinterpret_cast(impl); + i->destroy(i); + impl = 0; + } +#else + if (manager) + functor = manager(functor, detail::function::destroy_functor); + + manager = 0; + invoker = 0; +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + +#ifdef BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING + // Assignment from any functor + template + BOOST_FUNCTION_FUNCTION& operator=(Functor BOOST_MSVC_INCLUDE(const &) f) + { + clear(); + + if (!detail::function::has_empty_target(f)) { + // MSVC 6 eats the ';', so add another ';'. Don't ask me why. + assign_to(f);; + } + + return *this; + } +#else + template + BOOST_FUNCTION_FUNCTION& operator=(const Functor& f) + { + clear(); + + if (!detail::function::has_empty_target(&f)) { + typedef + typename detail::function::BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER< + Functor, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >::type + invoker_type; + +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS +# ifdef BOOST_NO_STD_ALLOCATOR + impl_type* i = new invoker_type(f); +# else + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + new (copy) invoker_type(f); + impl_type* i = static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + impl = static_cast(i); +# else + invoker = &invoker_type::invoke; + manager = &detail::function::functor_manager::manage; + functor = manager(detail::function::any_pointer(const_cast(&f)), + detail::function::clone_functor); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + + return *this; + } + + template + BOOST_FUNCTION_FUNCTION& + operator=(OtherR (*f)(BOOST_FUNCTION_OTHER_TEMPLATE_ARGS)) + { + clear(); + + if (f) { + typedef OtherR (*FunctionPtr)(BOOST_FUNCTION_OTHER_TEMPLATE_ARGS); + typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_INVOKER< + FunctionPtr, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >::type + invoker_type; + +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS +# ifdef BOOST_NO_STD_ALLOCATOR + impl_type* i = new invoker_type(f); +# else + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + new (copy) invoker_type(f); + impl_type* i = static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + impl = static_cast(i); +# else + invoker = &invoker_type::invoke; + manager = &detail::function::functor_manager::manage; + functor = manager(detail::function::any_pointer(reinterpret_cast(f)), + detail::function::clone_functor); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + + return *this; + } +#endif // BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING + +#ifdef BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING + // Assignment from any functor + template + void set(Functor BOOST_MSVC_INCLUDE(const &) f) + { + clear(); + + if (!detail::function::has_empty_target(f)) { + // MSVC 6 eats the ';', so add another ';'. Don't ask me why. + assign_to(f);; + } + } +#else + template + void set(const Functor& f) + { + clear(); + + if (!detail::function::has_empty_target(&f)) { + typedef + typename detail::function::BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER< + Functor, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >::type + invoker_type; + +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS +# ifdef BOOST_NO_STD_ALLOCATOR + impl_type* i = new invoker_type(f); +# else + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + new (copy) invoker_type(f); + impl_type* i = static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + impl = static_cast(i); +# else + invoker = &invoker_type::invoke; + manager = &detail::function::functor_manager::manage; + functor = manager(detail::function::any_pointer(const_cast(&f)), + detail::function::clone_functor); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + } + + template + void set(OtherR (*f)(BOOST_FUNCTION_OTHER_TEMPLATE_ARGS)) + { + clear(); + + if (f) { + typedef OtherR (*FunctionPtr)(BOOST_FUNCTION_OTHER_TEMPLATE_ARGS); + typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_INVOKER< + FunctionPtr, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >::type + invoker_type; + +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS +# ifdef BOOST_NO_STD_ALLOCATOR + impl_type* i = new invoker_type(f); +# else + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + new (copy) invoker_type(f); + impl_type* i = static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + impl = static_cast(i); +# else + invoker = &invoker_type::invoke; + manager = &detail::function::functor_manager + ::manage; + functor = manager(detail::function::any_pointer(reinterpret_cast(f)), + detail::function::clone_functor); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + } +#endif // BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING + + // Assignment from another BOOST_FUNCTION_FUNCTION + BOOST_FUNCTION_FUNCTION& operator=(const BOOST_FUNCTION_FUNCTION& f) + { + clear(); + + if (!f.empty()) { +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + const impl_type* other_impl = + reinterpret_cast(f.impl); + impl = static_cast(other_impl->clone()); +# else + invoker = f.invoker; + manager = f.manager; + functor = f.manager? + f.manager(f.functor, detail::function::clone_functor) : f.functor; +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + return *this; + } + + // Assignment from another BOOST_FUNCTION_FUNCTION + void set(const BOOST_FUNCTION_FUNCTION& f) + { + clear(); + + if (!f.empty()) { +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + const impl_type* other_impl = + reinterpret_cast(f.impl); + impl = static_cast(other_impl->clone()); +# else + invoker = f.invoker; + manager = f.manager; + functor = f.manager? + f.manager(f.functor, detail::function::clone_functor) : f.functor; +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + } + + protected: +#if defined BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING || defined BOOST_NO_DEPENDENT_BASE_LOOKUP + +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + // Clone a function pointer + template + void* clone_functor(FunctionPtr f, detail::function::function_ptr_tag) + { + typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_INVOKER< + FunctionPtr, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >::type + invoker_type; + +# ifdef BOOST_NO_STD_ALLOCATOR + impl_type* i = new invoker_type(f); +# else + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + new (copy) invoker_type(f); + impl_type* i = static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + return static_cast(i); + } + + // Clone a function object + template + void* clone_functor(FunctionObj& f, detail::function::function_obj_tag) + { + typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER< + FunctionObj, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >::type + invoker_type; + +# ifdef BOOST_NO_STD_ALLOCATOR + impl_type* i = new invoker_type(f); +# else + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + new (copy) invoker_type(f); + impl_type* i = static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + return static_cast(i); + } +# else + // Clone a function pointer + template + detail::function::any_pointer + clone_functor(FunctionPtr f, detail::function::function_ptr_tag) + { + detail::function::any_pointer a(reinterpret_cast(f)); + return manager(a, detail::function::clone_functor); + } + + // Clone a functor + template + detail::function::any_pointer + clone_functor(FunctionObj& f, detail::function::function_obj_tag) + { + detail::function::any_pointer a(static_cast(&f)); + return manager(a, detail::function::clone_functor); + } +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + + // Assign this BOOST_FUNCTION_FUNCTION to the given functor + template + void assign_to(Functor f) + { + // Do we have a functor or a function pointer? + typedef typename detail::function::IF< + (is_pointer::value), + detail::function::function_ptr_tag, + detail::function::function_obj_tag>::RET + target_type; + +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + impl = clone_functor(f, target_type()); +# else + typedef typename detail::function::IF<(is_pointer::value), + detail::function::BOOST_FUNCTION_GET_FUNCTION_INVOKER< + Functor, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >, + detail::function::BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER< + Functor, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + > + >::type + invoker_selector; + + typedef typename invoker_selector::type invoker_type; + + // Setup the new functor + invoker = &invoker_type::invoke; + manager = &detail::function::functor_manager::manage; + functor = clone_functor(f, target_type()); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } +#endif // BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING + +#ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + typedef result_type (*invoker_type)(detail::function::any_pointer, + bool BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + ); + + invoker_type invoker; +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + }; + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template< + BOOST_FUNCTION_TEMPLATE_PARMS BOOST_FUNCTION_COMMA + typename Policy, + typename Mixin, + typename Allocator + > + class BOOST_FUNCTION_FUNCTION< + void BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS, + Policy, + Mixin, + Allocator> : public function_base, public Mixin + { + public: + BOOST_STATIC_CONSTANT(int, args = BOOST_FUNCTION_NUM_ARGS); + + typedef void result_type; + typedef void R; + typedef Policy policy_type; + typedef Mixin mixin_type; + typedef Allocator allocator_type; + +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + private: + typedef detail::function::BOOST_FUNCTION_INVOKER_BASE< + result_type BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + > + impl_type; + + public: +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + + +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + // Construct without a target + BOOST_FUNCTION_FUNCTION() : function_base() {} +#else + // Construct without a target + BOOST_FUNCTION_FUNCTION() : function_base() +# ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + , invoker(0) +# endif + { + } + +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + +#ifdef BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING + // Clone the functor target f and make the clone the target + template + BOOST_FUNCTION_FUNCTION(Functor BOOST_MSVC_INCLUDE(const &) f) : + function_base() +# ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + , invoker(0) +# endif + { + if (!detail::function::has_empty_target(f)) + assign_to(f); + } +#else + template + BOOST_FUNCTION_FUNCTION(const Functor& f) : function_base() +# ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + , invoker(0) +# endif + { + if (!detail::function::has_empty_target(&f)) { + typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER< + Functor, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >::type + invoker_type; + +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS +# ifdef BOOST_NO_STD_ALLOCATOR + impl_type* i = new invoker_type(f); +# else + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + new (copy) invoker_type(f); + impl_type* i = static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + impl = static_cast(i); +# else + invoker = &invoker_type::invoke; + manager = &detail::function::functor_manager::manage; + functor = manager(detail::function::any_pointer(const_cast(&f)), + detail::function::clone_functor); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + } + + template + BOOST_FUNCTION_FUNCTION(OtherR (*f)( + BOOST_FUNCTION_OTHER_TEMPLATE_ARGS + )) : function_base() +# ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + , invoker(0) +# endif + { + if (f) { + typedef OtherR (*FunctionPtr)(BOOST_FUNCTION_OTHER_TEMPLATE_ARGS); + typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_INVOKER< + FunctionPtr, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >::type + invoker_type; + +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS +# ifdef BOOST_NO_STD_ALLOCATOR + impl_type* i = new invoker_type(f); +# else + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + new (copy) invoker_type(f); + impl_type* i = static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + impl = static_cast(i); +# else + invoker = &invoker_type::invoke; + manager = &detail::function::functor_manager::manage; + functor = manager(detail::function::any_pointer(reinterpret_cast(f)), + detail::function::clone_functor); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + } +#endif // BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING + + // Clone the input BOOST_FUNCTION_FUNCTION's target + BOOST_FUNCTION_FUNCTION(const BOOST_FUNCTION_FUNCTION& f): function_base() +# ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + , invoker(0) +# endif + { + if (!f.empty()) { +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + impl_type* other_impl = reinterpret_cast(f.impl); + impl = static_cast(other_impl->clone()); +# else + invoker = f.invoker; + manager = f.manager; + functor = f.manager(f.functor, detail::function::clone_functor); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + } + + // Destroy the target, if there is one + ~BOOST_FUNCTION_FUNCTION() { clear(); } + + void swap(BOOST_FUNCTION_FUNCTION& other) + { +# ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + std::swap(manager, other.manager); + std::swap(functor, other.functor); + std::swap(invoker, other.invoker); +# else + std::swap(impl, other.impl); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + + // Invoke the target + result_type operator()(BOOST_FUNCTION_PARMS) + { + assert(!this->empty()); + policy_type policy; + policy.precall(this); + +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + impl_type* i = reinterpret_cast(impl); + i->call(BOOST_FUNCTION_ARGS); +#else + invoker(functor, false BOOST_FUNCTION_COMMA BOOST_FUNCTION_ARGS); +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + + policy.postcall(this); + } + + result_type operator()(BOOST_FUNCTION_PARMS) const + { + assert(!this->empty()); + + policy_type policy; + policy.precall(this); + +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + const impl_type* i = reinterpret_cast(impl); + i->call(BOOST_FUNCTION_ARGS); +#else + invoker(functor, true BOOST_FUNCTION_COMMA BOOST_FUNCTION_ARGS); +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + + policy.postcall(this); + } + + // Clear out a target, if there is one + void clear() + { +#ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + if (impl) { + impl_type* i = reinterpret_cast(impl); + i->destroy(i); + impl = 0; + } +#else + if (manager) + functor = manager(functor, detail::function::destroy_functor); + + manager = 0; + invoker = 0; +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + +#ifdef BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING + // Assignment from any functor + template + BOOST_FUNCTION_FUNCTION& operator=(Functor BOOST_MSVC_INCLUDE(const &) f) + { + clear(); + + if (!detail::function::has_empty_target(f)) { + // MSVC 6 eats the ';', so add another ';'. Don't ask me why. + assign_to(f);; + } + + return *this; + } +#else + template + BOOST_FUNCTION_FUNCTION& operator=(const Functor& f) + { + clear(); + + if (!detail::function::has_empty_target(&f)) { + typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER< + Functor, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >::type + invoker_type; + +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS +# ifdef BOOST_NO_STD_ALLOCATOR + impl_type* i = new invoker_type(f); +# else + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + new (copy) invoker_type(f); + impl_type* i = static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + impl = static_cast(i); +# else + invoker = &invoker_type::invoke; + manager = &detail::function::functor_manager::manage; + functor = manager(detail::function::any_pointer(const_cast(&f)), + detail::function::clone_functor); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + + return *this; + } + + template + BOOST_FUNCTION_FUNCTION& + operator=(OtherR (*f)(BOOST_FUNCTION_OTHER_TEMPLATE_ARGS)) + { + clear(); + + if (f) { + typedef OtherR (*FunctionPtr)(BOOST_FUNCTION_OTHER_TEMPLATE_ARGS); + typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_INVOKER< + FunctionPtr, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >::type + invoker_type; + +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS +# ifdef BOOST_NO_STD_ALLOCATOR + impl_type* i = new invoker_type(f); +# else + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + new (copy) invoker_type(f); + impl_type* i = static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + impl = static_cast(i); +# else + invoker = &invoker_type::invoke; + manager = &detail::function::functor_manager::manage; + functor = manager(detail::function::any_pointer(reinterpret_cast(f)), + detail::function::clone_functor); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + + return *this; + } +#endif // BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING + +#ifdef BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING + // Assignment from any functor + template + void set(Functor BOOST_MSVC_INCLUDE(const &) f) + { + clear(); + + if (!detail::function::has_empty_target(f)) { + // MSVC 6 eats the ';', so add another ';'. Don't ask me why. + assign_to(f);; + } + } +#else + template + void set(const Functor& f) + { + clear(); + + if (!detail::function::has_empty_target(&f)) { + typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER< + Functor, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >::type + invoker_type; + +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS +# ifdef BOOST_NO_STD_ALLOCATOR + impl_type* i = new invoker_type(f); +# else + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + new (copy) invoker_type(f); + impl_type* i = static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + impl = static_cast(i); +# else + invoker = &invoker_type::invoke; + manager = &detail::function::functor_manager::manage; + functor = manager(detail::function::any_pointer(const_cast(&f)), + detail::function::clone_functor); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + } + + template + void set(OtherR (*f)(BOOST_FUNCTION_OTHER_TEMPLATE_ARGS)) + { + clear(); + + if (f) { + typedef OtherR (*FunctionPtr)(BOOST_FUNCTION_OTHER_TEMPLATE_ARGS); + typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_INVOKER< + FunctionPtr, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >::type + invoker_type; + +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS +# ifdef BOOST_NO_STD_ALLOCATOR + impl_type* i = new invoker_type(f); +# else + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + new (copy) invoker_type(f); + impl_type* i = static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + impl = static_cast(i); +# else + invoker = &invoker_type::invoke; + manager = &detail::function::functor_manager::manage; + functor = manager(detail::function::any_pointer(reinterpret_cast(f)), + detail::function::clone_functor); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + } +#endif // BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING + + // Assignment from another BOOST_FUNCTION_FUNCTION + BOOST_FUNCTION_FUNCTION& operator=(const BOOST_FUNCTION_FUNCTION& f) + { + clear(); + + if (!f.empty()) { +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + const impl_type* other_impl = + reinterpret_cast(f.impl); + impl = static_cast(other_impl->clone()); +# else + invoker = f.invoker; + manager = f.manager; + functor = f.manager? + f.manager(f.functor, detail::function::clone_functor) : f.functor; +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + return *this; + } + + // Assignment from another BOOST_FUNCTION_FUNCTION + void set(const BOOST_FUNCTION_FUNCTION& f) + { + clear(); + + if (!f.empty()) { +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + const impl_type* other_impl = + reinterpret_cast(f.impl); + impl = static_cast(other_impl->clone()); +# else + invoker = f.invoker; + manager = f.manager; + functor = f.manager? + f.manager(f.functor, detail::function::clone_functor) : f.functor; +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } + } + + protected: +#if defined BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING || defined BOOST_NO_DEPENDENT_BASE_LOOKUP + +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + // Clone a function pointer + template + void* clone_functor(FunctionPtr f, detail::function::function_ptr_tag) + { + typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_INVOKER< + FunctionPtr, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >::type + invoker_type; + +# ifdef BOOST_NO_STD_ALLOCATOR + impl_type* i = new invoker_type(f); +# else + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + new (copy) invoker_type(f); + impl_type* i = static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + return static_cast(i); + } + + // Clone a function object + template + void* clone_functor(FunctionObj& f, detail::function::function_obj_tag) + { + typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER< + FunctionObj, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >::type + invoker_type; + +# ifdef BOOST_NO_STD_ALLOCATOR + impl_type* i = new invoker_type(f); +# else + typedef typename Allocator::template rebind::other + allocator_type; + typedef typename allocator_type::pointer pointer_type; + allocator_type allocator; + + pointer_type copy = allocator.allocate(1); + new (copy) invoker_type(f); + impl_type* i = static_cast(copy); +# endif // BOOST_NO_STD_ALLOCATOR + return static_cast(i); + } +# else + // Clone a function pointer + template + detail::function::any_pointer clone_functor(FunctionPtr f, detail::function::function_ptr_tag) + { + detail::function::any_pointer a(reinterpret_cast(f)); + return manager(a, detail::function::clone_functor); + } + + // Clone a functor + template + detail::function::any_pointer clone_functor(FunctionObj& f, detail::function::function_obj_tag) + { + detail::function::any_pointer a(static_cast(&f)); + return manager(a, detail::function::clone_functor); + } +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + + // Assign this BOOST_FUNCTION_FUNCTION to the given functor + template + void assign_to(Functor f) + { + // Do we have a functor or a function pointer? + typedef typename detail::function::IF<(is_pointer::value), + detail::function::function_ptr_tag, + detail::function::function_obj_tag>::RET + target_type; + +# ifdef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + impl = clone_functor(f, target_type()); +# else + typedef typename detail::function::IF<(is_pointer::value), + detail::function::BOOST_FUNCTION_GET_FUNCTION_INVOKER< + Functor, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + >, + detail::function::BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER< + Functor, + Allocator, + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + > + >::type + invoker_selector; + + typedef typename invoker_selector::type invoker_type; + + // Setup the new functor + invoker = &invoker_type::invoke; + manager = &detail::function::functor_manager::manage; + functor = clone_functor(f, target_type()); +# endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + } +#endif // BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING + +#ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + typedef result_type (*invoker_type)(detail::function::any_pointer, + bool BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS + ); + + invoker_type invoker; +#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS + }; + +#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + template + inline void swap(BOOST_FUNCTION_FUNCTION< + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS , + Policy, + Mixin, + Allocator + >& f1, + BOOST_FUNCTION_FUNCTION< + R BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS, + Policy, + Mixin, + Allocator + >& f2) + { + f1.swap(f2); + } + + +}