2 // Boost.Pointer Container
4 // Copyright Thorsten Ottosen 2003-2007. Use, modification and
5 // distribution is subject to the Boost Software License, Version
6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // For more information, see http://www.boost.org/libs/ptr_container/
12 #ifndef BOOST_PTR_CONTAINER_INDIRECT_FUN_HPP
13 #define BOOST_PTR_CONTAINER_INDIRECT_FUN_HPP
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
19 #include <boost/config.hpp>
21 #ifdef BOOST_NO_SFINAE
23 #include <boost/utility/result_of.hpp>
24 #include <boost/pointee.hpp>
25 #endif // BOOST_NO_SFINAE
27 #include <boost/assert.hpp>
38 #ifdef BOOST_NO_SFINAE
46 indirect_fun() : fun(Fun())
49 indirect_fun( Fun f
) : fun(f
)
53 #ifdef BOOST_NO_SFINAE
56 BOOST_DEDUCED_TYPENAME result_of
< Fun( BOOST_DEDUCED_TYPENAME pointee
<T
>::type
& ) >::type
58 operator()( const T
& r
) const
63 template< class T
, class U
>
64 #ifdef BOOST_NO_SFINAE
67 BOOST_DEDUCED_TYPENAME result_of
< Fun( BOOST_DEDUCED_TYPENAME pointee
<T
>::type
&,
68 BOOST_DEDUCED_TYPENAME pointee
<U
>::type
& ) >::type
70 operator()( const T
& r
, const U
& r2
) const
72 return fun( *r
, *r2
);
77 inline indirect_fun
<Fun
> make_indirect_fun( Fun f
)
79 return indirect_fun
<Fun
>( f
);
88 #ifdef BOOST_NO_SFINAE
92 class void_ptr_indirect_fun
97 void_ptr_indirect_fun() : fun(Fun())
100 void_ptr_indirect_fun( Fun f
) : fun(f
)
102 #ifdef BOOST_NO_SFINAE
105 BOOST_DEDUCED_TYPENAME result_of
< Fun( Arg1
& ) >::type
107 operator()( const void* r
) const
109 BOOST_ASSERT( r
!= 0 );
110 return fun( * static_cast<const Arg1
*>( r
) );
113 #ifdef BOOST_NO_SFINAE
116 BOOST_DEDUCED_TYPENAME result_of
< Fun( Arg1
&, Arg2
& ) >::type
118 operator()( const void* l
, const void* r
) const
120 BOOST_ASSERT( l
!= 0 && r
!= 0 );
121 return fun( * static_cast<const Arg1
*>( l
), * static_cast<const Arg2
*>( r
) );
125 template< class Arg
, class Fun
>
126 inline void_ptr_indirect_fun
<Fun
,Arg
> make_void_ptr_indirect_fun( Fun f
)
128 return void_ptr_indirect_fun
<Fun
,Arg
>( f
);
131 } // namespace 'boost'