Click here to Skip to main content
15,886,757 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 291.6K   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_RESOLUTION_0
#    define FD_RESOLUTION_0
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 1
#  ifndef FD_RESOLUTION_1
#    define FD_RESOLUTION_1
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 2
#  ifndef FD_RESOLUTION_2
#    define FD_RESOLUTION_2
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 3
#  ifndef FD_RESOLUTION_3
#    define FD_RESOLUTION_3
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 4
#  ifndef FD_RESOLUTION_4
#    define FD_RESOLUTION_4
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 5
#  ifndef FD_RESOLUTION_5
#    define FD_RESOLUTION_5
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 6
#  ifndef FD_RESOLUTION_6
#    define FD_RESOLUTION_6
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 7
#  ifndef FD_RESOLUTION_7
#    define FD_RESOLUTION_7
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 8
#  ifndef FD_RESOLUTION_8
#    define FD_RESOLUTION_8
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 9
#  ifndef FD_RESOLUTION_9
#    define FD_RESOLUTION_9
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 10
#  ifndef FD_RESOLUTION_10
#    define FD_RESOLUTION_10
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 11
#  ifndef FD_RESOLUTION_11
#    define FD_RESOLUTION_11
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 12
#  ifndef FD_RESOLUTION_12
#    define FD_RESOLUTION_12
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 13
#  ifndef FD_RESOLUTION_13
#    define FD_RESOLUTION_13
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 14
#  ifndef FD_RESOLUTION_14
#    define FD_RESOLUTION_14
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 15
#  ifndef FD_RESOLUTION_15
#    define FD_RESOLUTION_15
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 16
#  ifndef FD_RESOLUTION_16
#    define FD_RESOLUTION_16
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 17
#  ifndef FD_RESOLUTION_17
#    define FD_RESOLUTION_17
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 18
#  ifndef FD_RESOLUTION_18
#    define FD_RESOLUTION_18
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 19
#  ifndef FD_RESOLUTION_19
#    define FD_RESOLUTION_19
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 20
#  ifndef FD_RESOLUTION_20
#    define FD_RESOLUTION_20
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 21
#  ifndef FD_RESOLUTION_21
#    define FD_RESOLUTION_21
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 22
#  ifndef FD_RESOLUTION_22
#    define FD_RESOLUTION_22
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 23
#  ifndef FD_RESOLUTION_23
#    define FD_RESOLUTION_23
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 24
#  ifndef FD_RESOLUTION_24
#    define FD_RESOLUTION_24
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 25
#  ifndef FD_RESOLUTION_25
#    define FD_RESOLUTION_25
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 26
#  ifndef FD_RESOLUTION_26
#    define FD_RESOLUTION_26
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 27
#  ifndef FD_RESOLUTION_27
#    define FD_RESOLUTION_27
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 28
#  ifndef FD_RESOLUTION_28
#    define FD_RESOLUTION_28
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 29
#  ifndef FD_RESOLUTION_29
#    define FD_RESOLUTION_29
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 30
#  ifndef FD_RESOLUTION_30
#    define FD_RESOLUTION_30
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 31
#  ifndef FD_RESOLUTION_31
#    define FD_RESOLUTION_31
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 32
#  ifndef FD_RESOLUTION_32
#    define FD_RESOLUTION_32
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 33
#  ifndef FD_RESOLUTION_33
#    define FD_RESOLUTION_33
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 34
#  ifndef FD_RESOLUTION_34
#    define FD_RESOLUTION_34
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 35
#  ifndef FD_RESOLUTION_35
#    define FD_RESOLUTION_35
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 36
#  ifndef FD_RESOLUTION_36
#    define FD_RESOLUTION_36
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 37
#  ifndef FD_RESOLUTION_37
#    define FD_RESOLUTION_37
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 38
#  ifndef FD_RESOLUTION_38
#    define FD_RESOLUTION_38
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 39
#  ifndef FD_RESOLUTION_39
#    define FD_RESOLUTION_39
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 40
#  ifndef FD_RESOLUTION_40
#    define FD_RESOLUTION_40
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 41
#  ifndef FD_RESOLUTION_41
#    define FD_RESOLUTION_41
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 42
#  ifndef FD_RESOLUTION_42
#    define FD_RESOLUTION_42
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 43
#  ifndef FD_RESOLUTION_43
#    define FD_RESOLUTION_43
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 44
#  ifndef FD_RESOLUTION_44
#    define FD_RESOLUTION_44
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 45
#  ifndef FD_RESOLUTION_45
#    define FD_RESOLUTION_45
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 46
#  ifndef FD_RESOLUTION_46
#    define FD_RESOLUTION_46
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 47
#  ifndef FD_RESOLUTION_47
#    define FD_RESOLUTION_47
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 48
#  ifndef FD_RESOLUTION_48
#    define FD_RESOLUTION_48
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 49
#  ifndef FD_RESOLUTION_49
#    define FD_RESOLUTION_49
#    include "../resolution_template.hpp"
#  endif
#elif FD_DELEGATE_NUM_ARGS == 50
#  ifndef FD_RESOLUTION_50
#    define FD_RESOLUTION_50
#    include "../resolution_template.hpp"
#  endif
#else
#  error Cannot handle fd.resolution 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