1 /*============================================================================= 2 Copyright (c) 2001-2011 Joel de Guzman 3 Copyright (c) 2011 Eric Niebler 4 5 Distributed under the Boost Software License, Version 1.0. (See accompanying 6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 ==============================================================================*/ 8 #if !defined(FUSION_FIND_05052005_1107) 9 #define FUSION_FIND_05052005_1107 10 11 #include <boost/fusion/support/config.hpp> 12 #include <boost/fusion/algorithm/query/find_if_fwd.hpp> 13 #include <boost/fusion/algorithm/query/detail/find_if.hpp> 14 #include <boost/fusion/algorithm/query/detail/segmented_find.hpp> 15 #include <boost/fusion/iterator/key_of.hpp> 16 #include <boost/fusion/iterator/value_of.hpp> 17 #include <boost/fusion/support/category_of.hpp> 18 #include <boost/fusion/support/is_segmented.hpp> 19 #include <boost/mpl/if.hpp> 20 #include <boost/mpl/placeholders.hpp> 21 #include <boost/type_traits/is_same.hpp> 22 #include <boost/type_traits/is_const.hpp> 23 #include <boost/utility/enable_if.hpp> 24 25 namespace boost { namespace fusion 26 { 27 namespace result_of 28 { 29 template <typename Sequence, typename T> 30 struct find 31 : mpl::if_< 32 traits::is_segmented<Sequence> 33 , detail::result_of_segmented_find<Sequence, T> 34 , detail::result_of_find_if< 35 Sequence, 36 is_same< 37 typename mpl::if_< 38 traits::is_associative<Sequence> 39 , key_of<mpl::_1> 40 , value_of<mpl::_1> 41 >::type 42 , T 43 > 44 > 45 >::type 46 {}; 47 } 48 49 template <typename T, typename Sequence> 50 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED 51 inline typename 52 lazy_disable_if< 53 is_const<Sequence> 54 , result_of::find<Sequence, T> 55 >::type const find(Sequence & seq)56 find(Sequence& seq) 57 { 58 typedef typename result_of::find<Sequence, T>::filter filter; 59 return filter::call(seq); 60 } 61 62 template <typename T, typename Sequence> 63 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED 64 inline typename result_of::find<Sequence const, T>::type const find(Sequence const & seq)65 find(Sequence const& seq) 66 { 67 typedef typename result_of::find<Sequence const, T>::filter filter; 68 return filter::call(seq); 69 } 70 }} 71 72 #endif 73