123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403 |
- #ifndef BOOST_BIND_MEM_FN_HPP_INCLUDED
- #define BOOST_BIND_MEM_FN_HPP_INCLUDED
- // MS compatible compilers support #pragma once
- #if defined(_MSC_VER) && (_MSC_VER >= 1020)
- # pragma once
- #endif
- //
- // mem_fn.hpp - a generalization of std::mem_fun[_ref]
- //
- // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
- // Copyright (c) 2001 David Abrahams
- // Copyright (c) 2003-2005 Peter Dimov
- //
- // Distributed under the Boost Software License, Version 1.0. (See
- // accompanying file LICENSE_1_0.txt or copy at
- // http://www.boost.org/LICENSE_1_0.txt)
- //
- // See http://www.boost.org/libs/bind/mem_fn.html for documentation.
- //
- #include <boost/config.hpp>
- #include <boost/get_pointer.hpp>
- #include <boost/detail/workaround.hpp>
- namespace boost
- {
- #if defined(BOOST_NO_VOID_RETURNS)
- #define BOOST_MEM_FN_CLASS_F , class F
- #define BOOST_MEM_FN_TYPEDEF(X)
- namespace _mfi // mem_fun_impl
- {
- template<class V> struct mf
- {
- #define BOOST_MEM_FN_RETURN return
- #define BOOST_MEM_FN_NAME(X) inner_##X
- #define BOOST_MEM_FN_CC
- #include <boost/bind/mem_fn_template.hpp>
- #undef BOOST_MEM_FN_CC
- #undef BOOST_MEM_FN_NAME
- #if defined(BOOST_MEM_FN_ENABLE_CDECL) && !defined(_M_X64)
- #define BOOST_MEM_FN_NAME(X) inner_##X##_cdecl
- #define BOOST_MEM_FN_CC __cdecl
- #include <boost/bind/mem_fn_template.hpp>
- #undef BOOST_MEM_FN_CC
- #undef BOOST_MEM_FN_NAME
- #endif
- #if defined(BOOST_MEM_FN_ENABLE_STDCALL) && !defined(_M_X64)
- #define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
- #define BOOST_MEM_FN_CC __stdcall
- #include <boost/bind/mem_fn_template.hpp>
- #undef BOOST_MEM_FN_CC
- #undef BOOST_MEM_FN_NAME
- #endif
- #if defined(BOOST_MEM_FN_ENABLE_FASTCALL) && !defined(_M_X64)
- #define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
- #define BOOST_MEM_FN_CC __fastcall
- #include <boost/bind/mem_fn_template.hpp>
- #undef BOOST_MEM_FN_CC
- #undef BOOST_MEM_FN_NAME
- #endif
- #undef BOOST_MEM_FN_RETURN
- }; // struct mf<V>
- template<> struct mf<void>
- {
- #define BOOST_MEM_FN_RETURN
- #define BOOST_MEM_FN_NAME(X) inner_##X
- #define BOOST_MEM_FN_CC
- #include <boost/bind/mem_fn_template.hpp>
- #undef BOOST_MEM_FN_CC
- #undef BOOST_MEM_FN_NAME
- #if defined(BOOST_MEM_FN_ENABLE_CDECL) && !defined(_M_X64)
- #define BOOST_MEM_FN_NAME(X) inner_##X##_cdecl
- #define BOOST_MEM_FN_CC __cdecl
- #include <boost/bind/mem_fn_template.hpp>
- #undef BOOST_MEM_FN_CC
- #undef BOOST_MEM_FN_NAME
- #endif
- #ifdef BOOST_MEM_FN_ENABLE_STDCALL
- #define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
- #define BOOST_MEM_FN_CC __stdcall
- #include <boost/bind/mem_fn_template.hpp>
- #undef BOOST_MEM_FN_CC
- #undef BOOST_MEM_FN_NAME
- #endif
- #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
- #define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
- #define BOOST_MEM_FN_CC __fastcall
- #include <boost/bind/mem_fn_template.hpp>
- #undef BOOST_MEM_FN_CC
- #undef BOOST_MEM_FN_NAME
- #endif
- #undef BOOST_MEM_FN_RETURN
- }; // struct mf<void>
- #undef BOOST_MEM_FN_CLASS_F
- #undef BOOST_MEM_FN_TYPEDEF_F
- #define BOOST_MEM_FN_NAME(X) X
- #define BOOST_MEM_FN_NAME2(X) inner_##X
- #define BOOST_MEM_FN_CC
- #include <boost/bind/mem_fn_vw.hpp>
- #undef BOOST_MEM_FN_NAME
- #undef BOOST_MEM_FN_NAME2
- #undef BOOST_MEM_FN_CC
- #if defined(BOOST_MEM_FN_ENABLE_CDECL) && !defined(_M_X64)
- #define BOOST_MEM_FN_NAME(X) X##_cdecl
- #define BOOST_MEM_FN_NAME2(X) inner_##X##_cdecl
- #define BOOST_MEM_FN_CC __cdecl
- #include <boost/bind/mem_fn_vw.hpp>
- #undef BOOST_MEM_FN_NAME
- #undef BOOST_MEM_FN_NAME2
- #undef BOOST_MEM_FN_CC
- #endif
- #ifdef BOOST_MEM_FN_ENABLE_STDCALL
- #define BOOST_MEM_FN_NAME(X) X##_stdcall
- #define BOOST_MEM_FN_NAME2(X) inner_##X##_stdcall
- #define BOOST_MEM_FN_CC __stdcall
- #include <boost/bind/mem_fn_vw.hpp>
- #undef BOOST_MEM_FN_NAME
- #undef BOOST_MEM_FN_NAME2
- #undef BOOST_MEM_FN_CC
- #endif
- #ifdef BOOST_MEM_FN_ENABLE_FASTCALL
- #define BOOST_MEM_FN_NAME(X) X##_fastcall
- #define BOOST_MEM_FN_NAME2(X) inner_##X##_fastcall
- #define BOOST_MEM_FN_CC __fastcall
- #include <boost/bind/mem_fn_vw.hpp>
- #undef BOOST_MEM_FN_NAME
- #undef BOOST_MEM_FN_NAME2
- #undef BOOST_MEM_FN_CC
- #endif
- } // namespace _mfi
- #else // #ifdef BOOST_NO_VOID_RETURNS
- #define BOOST_MEM_FN_CLASS_F
- #define BOOST_MEM_FN_TYPEDEF(X) typedef X;
- namespace _mfi
- {
- #define BOOST_MEM_FN_RETURN return
- #define BOOST_MEM_FN_NAME(X) X
- #define BOOST_MEM_FN_CC
- #include <boost/bind/mem_fn_template.hpp>
- #undef BOOST_MEM_FN_CC
- #undef BOOST_MEM_FN_NAME
- #if defined(BOOST_MEM_FN_ENABLE_CDECL) && !defined(_M_X64)
- #define BOOST_MEM_FN_NAME(X) X##_cdecl
- #define BOOST_MEM_FN_CC __cdecl
- #include <boost/bind/mem_fn_template.hpp>
- #undef BOOST_MEM_FN_CC
- #undef BOOST_MEM_FN_NAME
- #endif
- #if defined(BOOST_MEM_FN_ENABLE_STDCALL) && !defined(_M_X64)
- #define BOOST_MEM_FN_NAME(X) X##_stdcall
- #define BOOST_MEM_FN_CC __stdcall
- #include <boost/bind/mem_fn_template.hpp>
- #undef BOOST_MEM_FN_CC
- #undef BOOST_MEM_FN_NAME
- #endif
- #if defined(BOOST_MEM_FN_ENABLE_FASTCALL) && !defined(_M_X64)
- #define BOOST_MEM_FN_NAME(X) X##_fastcall
- #define BOOST_MEM_FN_CC __fastcall
- #include <boost/bind/mem_fn_template.hpp>
- #undef BOOST_MEM_FN_CC
- #undef BOOST_MEM_FN_NAME
- #endif
- #undef BOOST_MEM_FN_RETURN
- } // namespace _mfi
- #undef BOOST_MEM_FN_CLASS_F
- #undef BOOST_MEM_FN_TYPEDEF
- #endif // #ifdef BOOST_NO_VOID_RETURNS
- #define BOOST_MEM_FN_NAME(X) X
- #define BOOST_MEM_FN_CC
- #define BOOST_MEM_FN_NOEXCEPT
- #include <boost/bind/mem_fn_cc.hpp>
- #if defined( __cpp_noexcept_function_type ) || defined( _NOEXCEPT_TYPES_SUPPORTED )
- # undef BOOST_MEM_FN_NOEXCEPT
- # define BOOST_MEM_FN_NOEXCEPT noexcept
- # include <boost/bind/mem_fn_cc.hpp>
- #endif
- #undef BOOST_MEM_FN_NAME
- #undef BOOST_MEM_FN_CC
- #undef BOOST_MEM_FN_NOEXCEPT
- #if defined(BOOST_MEM_FN_ENABLE_CDECL) && !defined(_M_X64)
- #define BOOST_MEM_FN_NAME(X) X##_cdecl
- #define BOOST_MEM_FN_CC __cdecl
- #define BOOST_MEM_FN_NOEXCEPT
- #include <boost/bind/mem_fn_cc.hpp>
- #undef BOOST_MEM_FN_NAME
- #undef BOOST_MEM_FN_CC
- #undef BOOST_MEM_FN_NOEXCEPT
- #endif
- #if defined(BOOST_MEM_FN_ENABLE_STDCALL) && !defined(_M_X64)
- #define BOOST_MEM_FN_NAME(X) X##_stdcall
- #define BOOST_MEM_FN_CC __stdcall
- #define BOOST_MEM_FN_NOEXCEPT
- #include <boost/bind/mem_fn_cc.hpp>
- #undef BOOST_MEM_FN_NAME
- #undef BOOST_MEM_FN_CC
- #undef BOOST_MEM_FN_NOEXCEPT
- #endif
- #if defined(BOOST_MEM_FN_ENABLE_FASTCALL) && !defined(_M_X64)
- #define BOOST_MEM_FN_NAME(X) X##_fastcall
- #define BOOST_MEM_FN_CC __fastcall
- #define BOOST_MEM_FN_NOEXCEPT
- #include <boost/bind/mem_fn_cc.hpp>
- #undef BOOST_MEM_FN_NAME
- #undef BOOST_MEM_FN_CC
- #undef BOOST_MEM_FN_NOEXCEPT
- #endif
- // data member support
- namespace _mfi
- {
- template<class R, class T> class dm
- {
- public:
- typedef R const & result_type;
- typedef T const * argument_type;
- private:
-
- typedef R (T::*F);
- F f_;
- template<class U> R const & call(U & u, T const *) const
- {
- return (u.*f_);
- }
- template<class U> R const & call(U & u, void const *) const
- {
- return (get_pointer(u)->*f_);
- }
- public:
-
- explicit dm(F f): f_(f) {}
- R & operator()(T * p) const
- {
- return (p->*f_);
- }
- R const & operator()(T const * p) const
- {
- return (p->*f_);
- }
- template<class U> R const & operator()(U const & u) const
- {
- return call(u, &u);
- }
- #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) && !BOOST_WORKAROUND(__MWERKS__, < 0x3200)
- R & operator()(T & t) const
- {
- return (t.*f_);
- }
- R const & operator()(T const & t) const
- {
- return (t.*f_);
- }
- #endif
- bool operator==(dm const & rhs) const
- {
- return f_ == rhs.f_;
- }
- bool operator!=(dm const & rhs) const
- {
- return f_ != rhs.f_;
- }
- };
- } // namespace _mfi
- template<class R, class T> _mfi::dm<R, T> mem_fn(R T::*f)
- {
- return _mfi::dm<R, T>(f);
- }
- } // namespace boost
- #endif // #ifndef BOOST_BIND_MEM_FN_HPP_INCLUDED
|