Click here to Skip to main content
15,895,011 members
Articles / Programming Languages / C++

Fast C++ Delegate: Boost.Function 'drop-in' replacement and multicast

Rate me:
Please Sign up or sign in to vote.
4.86/5 (51 votes)
1 Jun 200733 min read 292.7K   1.9K   110  
An article on the implementation of a fast C++ delegate with many advanced features.
//  FD.Bind Library

//  Copyright JaeWook Choi 2007. Use, modification and
//  distribution is subject to the Boost Software License, Version
//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)

#include <boost/preprocessor/iterate.hpp>
#include <boost/detail/workaround.hpp>

#ifndef FD_DELEGATE_MAX_ARGS
#  define FD_DELEGATE_MAX_ARGS 10
#endif // FD_DELEGATE_MAX_ARGS

// Include the prologue here so that the use of file-level iteration
// in anything that may be included by delegate_template.hpp doesn't break
#include "./bind/detail/prolouge.hpp"

// Visual Age C++ doesn't handle the file iteration well
#if BOOST_WORKAROUND(__IBMCPP__, >= 500)
#  if FD_DELEGATE_MAX_ARGS >= 0
#    include "./bind/bind0.hpp"
#  endif
#  if FD_DELEGATE_MAX_ARGS >= 1
#    include "./bind/bind1.hpp"
#  endif
#  if FD_DELEGATE_MAX_ARGS >= 2
#    include "./bind/bind2.hpp"
#  endif
#  if FD_DELEGATE_MAX_ARGS >= 3
#    include "./bind/bind3.hpp"
#  endif
#  if FD_DELEGATE_MAX_ARGS >= 4
#    include "./bind/bind4.hpp"
#  endif
#  if FD_DELEGATE_MAX_ARGS >= 5
#    include "./bind/bind5.hpp"
#  endif
#  if FD_DELEGATE_MAX_ARGS >= 6
#    include "./bind/bind6.hpp"
#  endif
#  if FD_DELEGATE_MAX_ARGS >= 7
#    include "./bind/bind7.hpp"
#  endif
#  if FD_DELEGATE_MAX_ARGS >= 8
#    include "./bind/bind8.hpp"
#  endif
#  if FD_DELEGATE_MAX_ARGS >= 9
#    include "./bind/bind9.hpp"
#  endif
#  if FD_DELEGATE_MAX_ARGS >= 10
#    include "./bind/bind10.hpp"
#  endif
#else

#  define BOOST_PP_ITERATION_PARAMS_1 (3,(0,FD_DELEGATE_MAX_ARGS,<fd/delegate/bind/detail/bind_iterate.hpp>))
#  include BOOST_PP_ITERATE()
#  undef BOOST_PP_ITERATION_PARAMS_1
#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Other
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions