Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:37

0001 // Boost.Bimap
0002 //
0003 // Copyright (c) 2006-2007 Matias Capeletto
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 // (See accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 /// \file container_adaptor/detail/comparison_adaptor.hpp
0010 /// \brief Comparison adaptor.
0011 
0012 #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_COMPARISON_ADAPTOR_HPP
0013 #define BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_COMPARISON_ADAPTOR_HPP
0014 
0015 #if defined(_MSC_VER)
0016 #pragma once
0017 #endif
0018 
0019 #include <boost/config.hpp>
0020 
0021 #include <boost/call_traits.hpp>
0022 
0023 namespace boost {
0024 namespace bimaps {
0025 namespace container_adaptor {
0026 namespace detail {
0027 
0028 /// \brief Comparison adaptor
0029 /**
0030 
0031 A simple comparison adaptor.
0032                                                                                     **/
0033 
0034 template < class Compare, class NewType, class Converter >
0035 struct comparison_adaptor
0036 {
0037     typedef NewType first_argument_type;
0038     typedef NewType second_argument_type;
0039     typedef bool result_type;
0040 
0041     comparison_adaptor( const Compare & comp, const Converter & conv)
0042         : compare(comp), converter(conv) {}
0043 
0044     bool operator()( BOOST_DEDUCED_TYPENAME call_traits<NewType>::param_type x,
0045                      BOOST_DEDUCED_TYPENAME call_traits<NewType>::param_type y) const
0046     {
0047         return compare( converter(x), converter(y) );
0048     }
0049 
0050     private:
0051     Compare     compare;
0052     Converter   converter;
0053 };
0054 
0055 template < class Compare, class NewType, class Converter >
0056 struct compatible_comparison_adaptor
0057 {
0058     typedef NewType first_argument_type;
0059     typedef NewType second_argument_type;
0060     typedef bool result_type;
0061 
0062     compatible_comparison_adaptor( const Compare & comp, const Converter & conv)
0063         : compare(comp), converter(conv) {}
0064 
0065     template< class CompatibleTypeLeft, class CompatibleTypeRight >
0066     bool operator()( const CompatibleTypeLeft  & x,
0067                      const CompatibleTypeRight & y) const
0068     {
0069         return compare( converter(x), converter(y) );
0070     }
0071 
0072     private:
0073     Compare     compare;
0074     Converter   converter;
0075 };
0076 
0077 
0078 /// \brief Unary Check adaptor
0079 /**
0080 
0081 A simple unary check adaptor.
0082                                                                                     **/
0083 
0084 template < class Compare, class NewType, class Converter >
0085 struct unary_check_adaptor
0086 {
0087     typedef BOOST_DEDUCED_TYPENAME call_traits<NewType>::param_type argument_type;
0088     typedef bool result_type;
0089 
0090     unary_check_adaptor( const Compare & comp, const Converter & conv ) :
0091         compare(comp), converter(conv) {}
0092 
0093     bool operator()( BOOST_DEDUCED_TYPENAME call_traits<NewType>::param_type x) const
0094     {
0095         return compare( converter(x) );
0096     }
0097 
0098     private:
0099     Compare   compare;
0100     Converter converter;
0101 };
0102 
0103 } // namespace detail
0104 } // namespace container_adaptor
0105 } // namespace bimaps
0106 } // namespace boost
0107 
0108 
0109 #endif // BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_COMPARISON_ADAPTOR_HPP
0110 
0111