]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/bind/doc/mem_fn/faq.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / bind / doc / mem_fn / faq.qbk
CommitLineData
7c673cae
FG
1[/
2 / Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
3 / Copyright (c) 2003-2005 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 Can `mem_fn` be used instead of the standard `std::mem_fun[_ref]`
13adaptors?]
14
15Yes. For simple uses, `mem_fn` provides additional functionality that the
16standard adaptors do not. Complicated expressions that use `std::bind1st`,
17`std::bind2nd` or [@http://www.boost.org/doc/libs/1_31_0/libs/compose/index.htm Boost.Compose]
18along with the standard adaptors can be rewritten using `boost::bind` that
19automatically takes advantage of `mem_fn`.
20
21[endsect]
22
23[section Should I replace every occurence of `std::mem_fun[_ref]` with
24`mem_fn` in my existing code?]
25
26No, unless you have good reasons to do so. `mem_fn` is not 100% compatible
27with the standard adaptors, although it comes pretty close. In particular,
28`mem_fn` does not return objects of type `std::[const_]mem_fun[1][_ref]_t`, as
29the standard adaptors do, and it is not possible to fully describe the type of
30the first argument using the standard `argument_type` and `first_argument_type`
31nested typedefs. Libraries that need adaptable function objects in order to
32function might not like `mem_fn`.
33
34[endsect]
35
36[section Does `mem_fn` work with COM methods?]
37
38Yes, if you [link mem_fn.implementation.stdcall `#define BOOST_MEM_FN_ENABLE_STDCALL].
39
40[endsect]
41
42[section Why isn't `BOOST_MEM_FN_ENABLE_STDCALL` defined automatically?]
43
44Non-portable extensions, in general, should default to off to prevent vendor
45lock-in. Had `BOOST_MEM_FN_ENABLE_STDCALL` been defined automatically, you
46could have accidentally taken advantage of it without realizing that your code
47is, perhaps, no longer portable. In addition, it is possible for the default
48calling convention to be `__stdcall`, in which case enabling `__stdcall`
49support will result in duplicate definitions.
50
51[endsect]
52
53[endsect]