empty.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #if !defined(FUSION_EMPTY_09162005_0335)
  7. #define FUSION_EMPTY_09162005_0335
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/sequence/intrinsic_fwd.hpp>
  10. #include <boost/fusion/sequence/intrinsic/size.hpp>
  11. #include <boost/mpl/bool.hpp>
  12. #include <boost/fusion/support/tag_of.hpp>
  13. namespace boost { namespace fusion
  14. {
  15. // Special tags:
  16. struct sequence_facade_tag;
  17. struct mpl_sequence_tag; // mpl sequence tag
  18. namespace extension
  19. {
  20. template <typename Tag>
  21. struct empty_impl
  22. {
  23. template <typename Sequence>
  24. struct apply
  25. : mpl::bool_<(result_of::size<Sequence>::value == 0)>
  26. {};
  27. };
  28. template <>
  29. struct empty_impl<sequence_facade_tag>
  30. {
  31. template <typename Sequence>
  32. struct apply : Sequence::template empty<Sequence> {};
  33. };
  34. template <>
  35. struct empty_impl<mpl_sequence_tag>;
  36. }
  37. namespace result_of
  38. {
  39. template <typename Sequence>
  40. struct empty
  41. : extension::empty_impl<typename detail::tag_of<Sequence>::type>::
  42. template apply<Sequence>
  43. {};
  44. }
  45. template <typename Sequence>
  46. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  47. inline typename result_of::empty<Sequence>::type
  48. empty(Sequence const&)
  49. {
  50. typedef typename result_of::empty<Sequence>::type result;
  51. return result();
  52. }
  53. }}
  54. #endif