PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/fusion/algorithm/query/detail/count.hpp

http://hadesmem.googlecode.com/
C++ Header | 78 lines | 59 code | 11 blank | 8 comment | 1 complexity | d779fcc8838f6f23a27d094a289d7c3e MD5 | raw file
 1/*=============================================================================
 2    Copyright (c) 2001-2006 Joel de Guzman
 3
 4    Distributed under the Boost Software License, Version 1.0. (See accompanying 
 5    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 6==============================================================================*/
 7#if !defined(FUSION_COUNT_09162005_0158)
 8#define FUSION_COUNT_09162005_0158
 9
10#include <boost/config.hpp>
11#include <boost/mpl/or.hpp>
12#include <boost/type_traits/is_convertible.hpp>
13#include <boost/fusion/support/detail/access.hpp>
14
15#if defined (BOOST_MSVC)
16#  pragma warning(push)
17#  pragma warning (disable: 4512) // assignment operator could not be generated.
18#endif
19
20namespace boost { namespace fusion { namespace detail
21{ 
22    template <bool is_convertible>
23    struct compare_convertible;
24
25    // T1 is convertible to T2 or vice versa
26    template <>
27    struct compare_convertible<true> 
28    {
29        template <typename T1, typename T2>
30        static bool
31        call(T1 const& x, T2 const& y)
32        {
33            return x == y;
34        }
35    };
36
37    // T1 is NOT convertible to T2 NOR vice versa
38    template <>
39    struct compare_convertible<false>
40    {
41        template <typename T1, typename T2>
42        static bool
43        call(T1 const&, T2 const&)
44        {
45            return false;
46        }
47    };
48
49    template <typename T1>
50    struct count_compare
51    {
52        typedef typename detail::call_param<T1>::type param;
53        count_compare(param in_x)
54            : x(in_x) {}
55
56        template <typename T2>
57        bool
58        operator()(T2 const& y)
59        {
60            return 
61                compare_convertible<
62                    mpl::or_<
63                        is_convertible<T1, T2>
64                      , is_convertible<T2, T1> 
65                    >::value
66                >::call(x, y);
67        }
68
69        param x;
70    };
71}}}
72
73#if defined (BOOST_MSVC)
74#  pragma warning(pop)
75#endif
76
77#endif
78