Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:35

0001 //
0002 // Boost.Pointer Container
0003 //
0004 //  Copyright Thorsten Ottosen 2003-2007. Use, modification and
0005 //  distribution is subject to the Boost Software License, Version
0006 //  1.0. (See accompanying file LICENSE_1_0.txt or copy at
0007 //  http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 // For more information, see http://www.boost.org/libs/ptr_container/
0010 //
0011 
0012 #ifndef BOOST_PTR_CONTAINER_INDIRECT_FUN_HPP
0013 #define BOOST_PTR_CONTAINER_INDIRECT_FUN_HPP
0014 
0015 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0016     #pragma once
0017 #endif
0018 
0019 #include <boost/config.hpp>
0020 
0021 #ifdef BOOST_NO_SFINAE
0022 #else
0023 #include <boost/utility/result_of.hpp>
0024 #include <boost/pointee.hpp>
0025 #endif // BOOST_NO_SFINAE
0026 
0027 #include <boost/assert.hpp>
0028 #include <boost/static_assert.hpp>
0029 #include <boost/type_traits/is_void.hpp>
0030 #include <functional>
0031 
0032 
0033 namespace boost
0034 {
0035 
0036     namespace ptr_container_detail
0037     {
0038         template <typename Type, typename Dummy>
0039         struct make_lazy
0040         {
0041             typedef typename Type::type type;
0042         };
0043     }
0044 
0045     template
0046     <
0047               class Fun
0048 #ifdef BOOST_NO_SFINAE
0049             , class Result = bool
0050 #endif
0051     >
0052     class indirect_fun
0053     {
0054         Fun fun;
0055     public:
0056         indirect_fun() : fun(Fun())
0057         { }
0058 
0059         indirect_fun( Fun f ) : fun(f)
0060         { }
0061 
0062         template< class T >
0063 #ifdef BOOST_NO_SFINAE
0064         Result
0065 #else
0066         typename boost::result_of< const Fun( typename pointee<T>::type& ) >::type
0067 #endif
0068         operator()( const T& r ) const
0069         {
0070             return fun( *r );
0071         }
0072 
0073         template< class T, class U >
0074 #ifdef BOOST_NO_SFINAE
0075         Result
0076 #else
0077         typename boost::result_of< const Fun( typename pointee<T>::type&,
0078                                               typename pointee<U>::type& ) >::type
0079 #endif
0080         operator()( const T& r, const U& r2 ) const
0081         {
0082             return fun( *r, *r2 );
0083         }
0084     };
0085 
0086     template< class Fun >
0087     inline indirect_fun<Fun> make_indirect_fun( Fun f )
0088     {
0089         return indirect_fun<Fun>( f );
0090     }
0091 
0092 
0093     template
0094     <
0095         class Fun,
0096         class Arg1,
0097         class Arg2 = Arg1
0098 #ifdef BOOST_NO_SFINAE
0099       , class Result = bool
0100 #endif
0101     >
0102     class void_ptr_indirect_fun
0103     {
0104         Fun fun;
0105 
0106     public:
0107 
0108         void_ptr_indirect_fun() : fun(Fun())
0109         { }
0110 
0111         void_ptr_indirect_fun( Fun f ) : fun(f)
0112         { }
0113 
0114         template< class Void >
0115 #ifdef BOOST_NO_SFINAE
0116         Result
0117 #else
0118         typename ptr_container_detail::make_lazy<
0119             boost::result_of<const Fun(const Arg1&)>, Void>::type
0120 #endif
0121         operator()( const Void* r ) const
0122         {
0123             BOOST_STATIC_ASSERT(boost::is_void<Void>::value);
0124             BOOST_ASSERT( r != 0 );
0125             return fun( * static_cast<const Arg1*>( r ) );
0126         }
0127 
0128         template< class Void >
0129 #ifdef BOOST_NO_SFINAE
0130         Result
0131 #else
0132         typename ptr_container_detail::make_lazy<
0133             boost::result_of<const Fun(const Arg1&, const Arg2&)>, Void>::type
0134 #endif
0135         operator()( const Void* l, const Void* r ) const
0136         {
0137             BOOST_STATIC_ASSERT(boost::is_void<Void>::value);
0138             BOOST_ASSERT( l != 0 && r != 0 );
0139             return fun( * static_cast<const Arg1*>( l ), * static_cast<const Arg2*>( r ) );
0140         }
0141     };
0142 
0143     template< class Arg, class Fun >
0144     inline void_ptr_indirect_fun<Fun,Arg> make_void_ptr_indirect_fun( Fun f )
0145     {
0146         return void_ptr_indirect_fun<Fun,Arg>( f );
0147     }
0148 
0149 } // namespace 'boost'
0150 
0151 #endif