source: NonGTP/Boost/boost/mpl/multiset/aux_/count_impl.hpp @ 857

Revision 857, 2.2 KB checked in by igarcia, 19 years ago (diff)
Line 
1
2#ifndef BOOST_MPL_MULTISET_AUX_COUNT_IMPL_HPP_INCLUDED
3#define BOOST_MPL_MULTISET_AUX_COUNT_IMPL_HPP_INCLUDED
4
5// Copyright Aleksey Gurtovoy 2003-2004
6//
7// Distributed under the Boost Software License, Version 1.0.
8// (See accompanying file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt)
10//
11// See http://www.boost.org/libs/mpl for documentation.
12
13// $Source: /cvsroot/boost/boost/boost/mpl/multiset/aux_/count_impl.hpp,v $
14// $Date: 2004/09/02 15:41:02 $
15// $Revision: 1.2 $
16
17#include <boost/mpl/multiset/aux_/tag.hpp>
18#include <boost/mpl/count_fwd.hpp>
19#include <boost/mpl/int.hpp>
20#include <boost/mpl/aux_/type_wrapper.hpp>
21#include <boost/mpl/aux_/static_cast.hpp>
22#include <boost/mpl/aux_/config/static_constant.hpp>
23#include <boost/mpl/aux_/config/workaround.hpp>
24#include <boost/mpl/aux_/config/msvc.hpp>
25
26#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
27#   include <boost/mpl/if.hpp>
28#   include <boost/type_traits/is_reference.hpp>
29#endif
30
31namespace boost { namespace mpl {
32
33#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
34
35namespace aux {
36template< typename S, typename U >
37struct multiset_count_impl
38    : int_< sizeof(S::key_count(BOOST_MPL_AUX_STATIC_CAST(U*,0))) - 1 >
39{
40};
41
42template< typename S, typename U >
43struct multiset_count_ref_impl
44{
45    typedef U (* u_)();
46    typedef int_< sizeof(S::ref_key_count(BOOST_MPL_AUX_STATIC_CAST(u_,0))) - 1 > type_;
47    BOOST_STATIC_CONSTANT(int, value = type_::value);
48    typedef type_ type;
49};
50}
51
52template<>
53struct count_impl< aux::multiset_tag >
54{
55    template< typename Set, typename Key > struct apply
56        : if_<
57              is_reference<Key>
58            , aux::multiset_count_ref_impl<Set,Key>
59            , aux::multiset_count_impl<Set,Key>
60            >::type
61    {
62    };
63};
64
65#else
66
67template<>
68struct count_impl< aux::multiset_tag >
69{
70    template< typename Set, typename Key > struct apply
71    {
72        enum { msvc71_wknd_ = sizeof(Set::key_count(BOOST_MPL_AUX_STATIC_CAST(aux::type_wrapper<Key>*,0))) - 1 };
73        typedef int_< msvc71_wknd_ > type;
74        BOOST_STATIC_CONSTANT(int, value = msvc71_wknd_);
75    };
76};
77
78#endif // BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
79
80}}
81
82#endif // BOOST_MPL_MULTISET_AUX_COUNT_IMPL_HPP_INCLUDED
Note: See TracBrowser for help on using the repository browser.