Click here to Skip to main content
15,897,167 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 293.2K   1.9K   110  
An article on the implementation of a fast C++ delegate with many advanced features.
#if FD_DELEGATE_NUM_ARGS == 0
#  ifndef FD_BIND_0
#    define FD_BIND_0
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 1
#  ifndef FD_BIND_1
#    define FD_BIND_1
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 2
#  ifndef FD_BIND_2
#    define FD_BIND_2
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 3
#  ifndef FD_BIND_3
#    define FD_BIND_3
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 4
#  ifndef FD_BIND_4
#    define FD_BIND_4
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 5
#  ifndef FD_BIND_5
#    define FD_BIND_5
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 6
#  ifndef FD_BIND_6
#    define FD_BIND_6
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 7
#  ifndef FD_BIND_7
#    define FD_BIND_7
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 8
#  ifndef FD_BIND_8
#    define FD_BIND_8
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 9
#  ifndef FD_BIND_9
#    define FD_BIND_9
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 10
#  ifndef FD_BIND_10
#    define FD_BIND_10
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 11
#  ifndef FD_BIND_11
#    define FD_BIND_11
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 12
#  ifndef FD_BIND_12
#    define FD_BIND_12
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 13
#  ifndef FD_BIND_13
#    define FD_BIND_13
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 14
#  ifndef FD_BIND_14
#    define FD_BIND_14
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 15
#  ifndef FD_BIND_15
#    define FD_BIND_15
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 16
#  ifndef FD_BIND_16
#    define FD_BIND_16
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 17
#  ifndef FD_BIND_17
#    define FD_BIND_17
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 18
#  ifndef FD_BIND_18
#    define FD_BIND_18
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 19
#  ifndef FD_BIND_19
#    define FD_BIND_19
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 20
#  ifndef FD_BIND_20
#    define FD_BIND_20
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 21
#  ifndef FD_BIND_21
#    define FD_BIND_21
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 22
#  ifndef FD_BIND_22
#    define FD_BIND_22
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 23
#  ifndef FD_BIND_23
#    define FD_BIND_23
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 24
#  ifndef FD_BIND_24
#    define FD_BIND_24
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 25
#  ifndef FD_BIND_25
#    define FD_BIND_25
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 26
#  ifndef FD_BIND_26
#    define FD_BIND_26
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 27
#  ifndef FD_BIND_27
#    define FD_BIND_27
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 28
#  ifndef FD_BIND_28
#    define FD_BIND_28
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 29
#  ifndef FD_BIND_29
#    define FD_BIND_29
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 30
#  ifndef FD_BIND_30
#    define FD_BIND_30
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 31
#  ifndef FD_BIND_31
#    define FD_BIND_31
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 32
#  ifndef FD_BIND_32
#    define FD_BIND_32
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 33
#  ifndef FD_BIND_33
#    define FD_BIND_33
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 34
#  ifndef FD_BIND_34
#    define FD_BIND_34
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 35
#  ifndef FD_BIND_35
#    define FD_BIND_35
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 36
#  ifndef FD_BIND_36
#    define FD_BIND_36
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 37
#  ifndef FD_BIND_37
#    define FD_BIND_37
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 38
#  ifndef FD_BIND_38
#    define FD_BIND_38
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 39
#  ifndef FD_BIND_39
#    define FD_BIND_39
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 40
#  ifndef FD_BIND_40
#    define FD_BIND_40
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 41
#  ifndef FD_BIND_41
#    define FD_BIND_41
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 42
#  ifndef FD_BIND_42
#    define FD_BIND_42
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 43
#  ifndef FD_BIND_43
#    define FD_BIND_43
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 44
#  ifndef FD_BIND_44
#    define FD_BIND_44
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 45
#  ifndef FD_BIND_45
#    define FD_BIND_45
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 46
#  ifndef FD_BIND_46
#    define FD_BIND_46
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 47
#  ifndef FD_BIND_47
#    define FD_BIND_47
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 48
#  ifndef FD_BIND_48
#    define FD_BIND_48
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 49
#  ifndef FD_BIND_49
#    define FD_BIND_49
#    include "../bind_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 50
#  ifndef FD_BIND_50
#    define FD_BIND_50
#    include "../bind_template.hpp"
#  endif
#else
#  error Cannot handle fd.bind functions that accept more than 50 arguments!
#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