]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/bind/doc/bind/faq.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / bind / doc / bind / faq.qbk
CommitLineData
7c673cae
FG
1[/
2 / Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
3 / Copyright (c) 2003-2008 Peter Dimov
4 /
5 / Distributed under the Boost Software License, Version 1.0. (See
6 / accompanying file LICENSE_1_0.txt or copy at
7 / http://www.boost.org/LICENSE_1_0.txt)
8 /]
9
10[section:faq Frequently Asked Questions]
11
12[section Why doesn't this compile?]
13
14See the dedicated [link bind.troubleshooting Troubleshooting section].
15
16[endsect]
17
18[section Why does this compile? It should not.]
19
20Probably because you used the general `bind<R>(f, ...)` syntax, thereby
21instructing `bind` to not "inspect" f to detect arity and return type errors.
22
23[endsect]
24
25[section:Q_forms What is the difference between `bind(f, ...)` and `bind<R>(f, ...)`?]
26
27The first form instructs `bind` to inspect the type of `f` in order to
28determine its arity (number of arguments) and return type. Arity errors will
29be detected at "bind time". This syntax, of course, places some requirements
30on `f`. It must be a function, function pointer, member function pointer, or a
31function object that defines a nested type named `result_type`; in short, it
32must be something that `bind` can recognize.
33
34The second form instructs `bind` to not attempt to recognize the type of `f`.
35It is generally used with function objects that do not, or cannot, expose
36`result_type`, but it can also be used with nonstandard functions. For example,
37the current implementation does not automatically recognize variable-argument
38functions like `printf`, so you will have to use `bind<int>(printf, ...)`.
39Note that an alternative `bind(type<R>(), f, ...)` syntax is supported for
40portability reasons.
41
42Another important factor to consider is that compilers without partial
43template specialization or function template partial ordering support cannot
44handle the first form when `f` is a function object, and in most cases will
45not handle the second form when `f` is a function (pointer) or a member
46function pointer.
47
48[endsect]
49
50[section Does bind work with Windows API functions?]
51
52Yes, if you [link bind.implementation.stdcall `#define
53BOOST_BIND_ENABLE_STDCALL`]. An alternative is to treat the function as a
54[link bind.purpose.with_function_objects generic function object] and use the
55`bind<R>(f, ...)` syntax.
56
57[endsect]
58
59[section Does bind work with COM methods?]
60
61Yes, if you [link bind.implementation.stdcall `#define
62BOOST_MEM_FN_ENABLE_STDCALL`].
63
64[endsect]
65
66[section Does bind work with Mac toolbox functions?]
67
68Yes, if you [link bind.implementation.stdcall `#define
69BOOST_BIND_ENABLE_PASCAL`]. An alternative is to treat the function as a [link
70bind.purpose.with_function_objects generic function object] and use the
71`bind<R>(f, ...)` syntax.
72
73[endsect]
74
75[section Does bind work with extern "C" functions?]
76
77Sometimes. On some platforms, pointers to extern "C" functions are equivalent
78to "ordinary" function pointers, so they work fine. Other platforms treat them
79as different types. A platform-specific implementation of `bind` is expected
80to handle the problem transparently; this implementation does not. As usual,
81the workaround is to treat the function as a [link
82bind.purpose.with_function_objects generic function object] and use the
83`bind<R>(f, ...)` syntax.
84
85[endsect]
86
87[section Why doesn't bind automatically recognize nonstandard functions?]
88
89Non-portable extensions, in general, should default to off to prevent vendor
90lock-in. Had the [link bind.implementation.stdcall appropriate macros] been
91defined automatically, you could have accidentally taken advantage of them
92without realizing that your code is, perhaps, no longer portable. In addition,
93some compilers have the option to make `__stdcall` (`__fastcall`) their
94default calling convention, in which case no separate support would be
95necessary.
96
97[endsect]
98
99[endsect]