/Src/Dependencies/Boost/boost/fusion/sequence/intrinsic/size.hpp

http://hadesmem.googlecode.com/ · C++ Header · 74 lines · 55 code · 12 blank · 7 comment · 0 complexity · d9eaa446f1ac0ec3dcce3aa859d930c1 MD5 · raw file

  1. /*=============================================================================
  2. Copyright (c) 2001-2006 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_SIZE_05052005_0214)
  7. #define FUSION_SIZE_05052005_0214
  8. #include <boost/mpl/int.hpp>
  9. #include <boost/fusion/support/tag_of.hpp>
  10. namespace boost { namespace fusion
  11. {
  12. // Special tags:
  13. struct sequence_facade_tag;
  14. struct boost_tuple_tag; // boost::tuples::tuple tag
  15. struct boost_array_tag; // boost::array tag
  16. struct mpl_sequence_tag; // mpl sequence tag
  17. struct std_pair_tag; // std::pair tag
  18. namespace extension
  19. {
  20. template <typename Tag>
  21. struct size_impl
  22. {
  23. template <typename Sequence>
  24. struct apply : Sequence::size {};
  25. };
  26. template <>
  27. struct size_impl<sequence_facade_tag>
  28. {
  29. template <typename Sequence>
  30. struct apply : Sequence::template size<Sequence> {};
  31. };
  32. template <>
  33. struct size_impl<boost_tuple_tag>;
  34. template <>
  35. struct size_impl<boost_array_tag>;
  36. template <>
  37. struct size_impl<mpl_sequence_tag>;
  38. template <>
  39. struct size_impl<std_pair_tag>;
  40. }
  41. namespace result_of
  42. {
  43. template <typename Sequence>
  44. struct size
  45. : extension::size_impl<typename detail::tag_of<Sequence>::type>::
  46. template apply<Sequence>
  47. {
  48. typedef typename extension::size_impl<typename detail::tag_of<Sequence>::type>::
  49. template apply<Sequence>::type size_application;
  50. BOOST_STATIC_CONSTANT(int, value = size_application::value);
  51. };
  52. }
  53. template <typename Sequence>
  54. inline typename result_of::size<Sequence>::type
  55. size(Sequence const&)
  56. {
  57. typedef typename result_of::size<Sequence>::type result;
  58. return result();
  59. }
  60. }}
  61. #endif