Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:09:52

0001 /*=============================================================================
0002     Copyright (c) 2001-2011 Joel de Guzman
0003 
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 #if !defined(FUSION_EQUAL_TO_05052005_1208)
0008 #define FUSION_EQUAL_TO_05052005_1208
0009 
0010 #include <boost/fusion/support/config.hpp>
0011 #include <boost/type_traits/is_same.hpp>
0012 #include <boost/fusion/support/tag_of.hpp>
0013 #include <boost/type_traits/add_const.hpp>
0014 #include <boost/fusion/support/is_iterator.hpp>
0015 #include <boost/mpl/and.hpp>
0016 #include <boost/utility/enable_if.hpp>
0017 
0018 namespace boost { namespace fusion
0019 {
0020     // Special tags:
0021     struct iterator_facade_tag; // iterator facade tag
0022     struct boost_array_iterator_tag; // boost::array iterator tag
0023     struct mpl_iterator_tag; // mpl sequence iterator tag
0024     struct std_pair_iterator_tag; // std::pair iterator tag
0025 
0026     namespace extension
0027     {
0028         template <typename Tag>
0029         struct equal_to_impl
0030         {
0031             // default implementation
0032             template <typename I1, typename I2>
0033             struct apply
0034                 : is_same<typename add_const<I1>::type, typename add_const<I2>::type>
0035             {};
0036         };
0037 
0038         template <>
0039         struct equal_to_impl<iterator_facade_tag>
0040         {
0041             template <typename It1, typename It2, typename Tag1, typename Tag2>
0042             struct dispatch : mpl::false_ {};
0043 
0044             template <typename It1, typename It2, typename Tag>
0045             struct dispatch<It1, It2, Tag, Tag> // same tag
0046               : It1::template equal_to<It1, It2>
0047             {};
0048 
0049             template<typename It1, typename It2>
0050             struct apply : dispatch<It1, It2,
0051                 typename It1::fusion_tag, typename It2::fusion_tag>
0052             {};
0053         };
0054 
0055         template <>
0056         struct equal_to_impl<boost_array_iterator_tag>;
0057 
0058         template <>
0059         struct equal_to_impl<mpl_iterator_tag>;
0060 
0061         template <>
0062         struct equal_to_impl<std_pair_iterator_tag>;
0063     }
0064 
0065     namespace result_of
0066     {
0067         template <typename I1, typename I2>
0068         struct equal_to
0069             : extension::equal_to_impl<typename detail::tag_of<I1>::type>::
0070                 template apply<I1, I2>
0071         {};
0072     }
0073 
0074     namespace iterator_operators
0075     {
0076         template <typename Iter1, typename Iter2>
0077         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0078         inline typename
0079         boost::enable_if<
0080             mpl::and_<is_fusion_iterator<Iter1>, is_fusion_iterator<Iter2> >
0081             , bool
0082             >::type
0083         operator==(Iter1 const&, Iter2 const&)
0084         {
0085             return result_of::equal_to<Iter1, Iter2>::value;
0086         }
0087 
0088         template <typename Iter1, typename Iter2>
0089         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0090         inline typename
0091         boost::enable_if<
0092             mpl::and_<is_fusion_iterator<Iter1>, is_fusion_iterator<Iter2> >
0093             , bool
0094             >::type
0095         operator!=(Iter1 const&, Iter2 const&)
0096         {
0097             return !result_of::equal_to<Iter1, Iter2>::value;
0098         }
0099     }
0100 
0101     using iterator_operators::operator==;
0102     using iterator_operators::operator!=;
0103 }}
0104 
0105 #endif
0106