From 35ee2f3a521e381f9ea90b27822c992aaa92c0a5 Mon Sep 17 00:00:00 2001
From: Peter Dimov Does bind work with Mac toolbox
functions?
Does bind work with extern
- "C" functions?
+ "C" functions?
Why doesn't bind automatically
recognize nonstandard functions?
Troubleshooting
@@ -77,7 +77,8 @@
Files
Dependencies
Number of Arguments
- "__stdcall" and "pascal" Support
+ "__stdcall", "__fastcall", and
+ "pascal" Support
Using the BOOST_BIND macro
visit_each support
Acknowledgements
@@ -455,13 +456,13 @@ template<class T> void f(T const & t);
alternative is to treat the function as a generic
function object and use the bind<R>(f, ...) syntax.
- Sometimes. On some platforms, pointers to extern "C" functions are - equivalent to "ordinary" function pointers, so they work fine. Other - platforms treat them as different types. A platform-specific implementation of bind - is expected to handle the problem transparently; this implementation does not. - As usual, the workaround is to treat the function as a + Sometimes. On some platforms, pointers to extern "C" functions are equivalent + to "ordinary" function pointers, so they work fine. Other platforms treat them + as different types. A platform-specific implementation of bind is + expected to handle the problem transparently; this implementation does not. As + usual, the workaround is to treat the function as a generic function object and use the bind<R>(f, ...) syntax.
- On some platforms, extern "C" functions, like std::strcmp, are not + On some platforms, extern "C" functions, like std::strcmp, are not recognized by the short form of bind.
@@ -753,8 +755,8 @@ namespace Effects: Equivalent to bind<typename F::result_type, F>(f);
- Notes: Implementations are allowed to infer the return type of f - via other means as an extension, without relying on the result_type member. + Notes: Implementations are allowed to infer the return type of f via + other means as an extension, without relying on the result_type member.
- Notes: Implementations are allowed to infer the return type of f - via other means as an extension, without relying on the result_type member. + Notes: Implementations are allowed to infer the return type of f via + other means as an extension, without relying on the result_type member.
Effects: Equivalent to bind<R const &>(boost::mem_fn(f), @@ -852,8 +854,8 @@ namespace a1, a2);
- Notes: Implementations are allowed to infer the return type of f - via other means as an extension, without relying on the result_type member. + Notes: Implementations are allowed to infer the return type of f via + other means as an extension, without relying on the result_type member.
- Implementations are allowed to provide additional bind overloads in order to - support more arguments or different function pointer variations. + Implementations are allowed to provide additional bind overloads in + order to support more arguments or different function pointer variations.
Some platforms allow several types of (member) functions that differ by their calling convention (the rules by which the function is invoked: how are @@ -960,8 +962,8 @@ namespace
For example, Windows API functions and COM interface member functions use a - calling convention known as __stdcall. Mac toolbox functions use a pascal - calling convention. + calling convention known as __stdcall.Borland VCL components use __fastcall. + Mac toolbox functions use a pascal calling convention.
To use bind with __stdcall functions, #define the macro BOOST_BIND_ENABLE_STDCALL @@ -971,10 +973,16 @@ namespace To use bind with __stdcall member functions, #define the macro BOOST_MEM_FN_ENABLE_STDCALL before including <boost/bind.hpp>.
-+
To use bind with __fastcall functions, #define the macro BOOST_BIND_ENABLE_FASTCALL + before including <boost/bind.hpp>. +
+To use bind with __fastcall member functions, #define + the macro BOOST_MEM_FN_ENABLE_FASTCALL before including <boost/bind.hpp>. +
+To use bind with pascal functions, #define the macro BOOST_BIND_ENABLE_PASCAL before including <boost/bind.hpp>. -
+[Note: this is a non-portable extension. It is not part of the interface.]
diff --git a/bind_fastcall_mf_test.cpp b/bind_fastcall_mf_test.cpp new file mode 100644 index 0000000..dcf642b --- /dev/null +++ b/bind_fastcall_mf_test.cpp @@ -0,0 +1,165 @@ +#if defined(_MSC_VER) && !defined(__ICL) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +// +// bind_stdcall_mf_test.cpp - test for bind.hpp + __stdcall (member functions) +// +// Copyright (c) 2001 Peter Dimov and Multi Media Ltd. +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// + +#define BOOST_MEM_FN_ENABLE_FASTCALL + +#include@@ -321,7 +322,7 @@ template<class R, class T, class A1, class A2> implementation-defined-6 This implementation supports member functions with up to eight arguments. This is not an inherent limitation of the design, but an implementation detail.
-Some platforms allow several types of member functions that differ by their calling convention (the rules by which the function is invoked: how are @@ -330,16 +331,19 @@ template<class R, class T, class A1, class A2> implementation-defined-6
For example, Windows API functions and COM interface member functions use a - calling convention known as __stdcall. + calling convention known as __stdcall. Borland VCL components use __fastcall.
To use mem_fn with __stdcall member functions, #define the macro BOOST_MEM_FN_ENABLE_STDCALL before including, directly or indirectly, <boost/mem_fn.hpp>.
-- [Note: this is a non-portable extension. It is not part of the interface.] -
+To use mem_fn with __fastcall member functions, #define the + macro BOOST_MEM_FN_ENABLE_FASTCALL before including, directly or + indirectly, <boost/mem_fn.hpp>. +
+[Note: this is a non-portable extension. It is not part of the interface.] +
[Note: Some compilers provide only minimal support for the __stdcall keyword.]
diff --git a/mem_fn_fastcall_test.cpp b/mem_fn_fastcall_test.cpp new file mode 100644 index 0000000..ca26273 --- /dev/null +++ b/mem_fn_fastcall_test.cpp @@ -0,0 +1,185 @@ +#if defined(_MSC_VER) && !defined(__ICL) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +// +// mem_fn_fastcall_test.cpp - a test for mem_fn.hpp + __fastcall +// +// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// + +#define BOOST_MEM_FN_ENABLE_FASTCALL + +#include