1 | /*============================================================================= |
---|---|
2 | Copyright (c) 2001-2011 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_EMPTY_09162005_0335) |
8 | #define FUSION_EMPTY_09162005_0335 |
9 | |
10 | #include <boost/fusion/support/config.hpp> |
11 | #include <boost/fusion/sequence/intrinsic_fwd.hpp> |
12 | #include <boost/fusion/sequence/intrinsic/size.hpp> |
13 | #include <boost/mpl/bool.hpp> |
14 | #include <boost/fusion/support/tag_of.hpp> |
15 | |
16 | namespace boost { namespace fusion |
17 | { |
18 | // Special tags: |
19 | struct sequence_facade_tag; |
20 | struct mpl_sequence_tag; // mpl sequence tag |
21 | |
22 | namespace extension |
23 | { |
24 | template <typename Tag> |
25 | struct empty_impl |
26 | { |
27 | template <typename Sequence> |
28 | struct apply |
29 | : mpl::bool_<(result_of::size<Sequence>::value == 0)> |
30 | {}; |
31 | }; |
32 | |
33 | template <> |
34 | struct empty_impl<sequence_facade_tag> |
35 | { |
36 | template <typename Sequence> |
37 | struct apply : Sequence::template empty<Sequence> {}; |
38 | }; |
39 | |
40 | template <> |
41 | struct empty_impl<mpl_sequence_tag>; |
42 | } |
43 | |
44 | namespace result_of |
45 | { |
46 | template <typename Sequence> |
47 | struct empty |
48 | : extension::empty_impl<typename detail::tag_of<Sequence>::type>:: |
49 | template apply<Sequence> |
50 | {}; |
51 | } |
52 | |
53 | template <typename Sequence> |
54 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED |
55 | inline typename result_of::empty<Sequence>::type |
56 | empty(Sequence const&) |
57 | { |
58 | typedef typename result_of::empty<Sequence>::type result; |
59 | return result(); |
60 | } |
61 | }} |
62 | |
63 | #endif |
64 |