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