O1_size_impl.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef BOOST_MPL_O1_SIZE_IMPL_HPP_INCLUDED
  2. #define BOOST_MPL_O1_SIZE_IMPL_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2000-2004
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/mpl for documentation.
  10. // $Id$
  11. // $Date$
  12. // $Revision$
  13. #include <boost/mpl/O1_size_fwd.hpp>
  14. #include <boost/mpl/long.hpp>
  15. #include <boost/mpl/if.hpp>
  16. #include <boost/mpl/aux_/has_size.hpp>
  17. #include <boost/mpl/aux_/config/forwarding.hpp>
  18. #include <boost/mpl/aux_/config/static_constant.hpp>
  19. #include <boost/mpl/aux_/config/msvc.hpp>
  20. #include <boost/mpl/aux_/config/workaround.hpp>
  21. namespace boost { namespace mpl {
  22. // default implementation - returns 'Sequence::size' if sequence has a 'size'
  23. // member, and -1 otherwise; conrete sequences might override it by
  24. // specializing either the 'O1_size_impl' or the primary 'O1_size' template
  25. # if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) \
  26. && !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
  27. namespace aux {
  28. template< typename Sequence > struct O1_size_impl
  29. : Sequence::size
  30. {
  31. };
  32. }
  33. template< typename Tag >
  34. struct O1_size_impl
  35. {
  36. template< typename Sequence > struct apply
  37. #if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING)
  38. : if_<
  39. aux::has_size<Sequence>
  40. , aux::O1_size_impl<Sequence>
  41. , long_<-1>
  42. >::type
  43. {
  44. #else
  45. {
  46. typedef typename if_<
  47. aux::has_size<Sequence>
  48. , aux::O1_size_impl<Sequence>
  49. , long_<-1>
  50. >::type type;
  51. BOOST_STATIC_CONSTANT(long, value =
  52. (if_<
  53. aux::has_size<Sequence>
  54. , aux::O1_size_impl<Sequence>
  55. , long_<-1>
  56. >::type::value)
  57. );
  58. #endif
  59. };
  60. };
  61. # else // BOOST_MSVC
  62. template< typename Tag >
  63. struct O1_size_impl
  64. {
  65. template< typename Sequence > struct apply
  66. : long_<-1>
  67. {
  68. };
  69. };
  70. # endif
  71. }}
  72. #endif // BOOST_MPL_O1_SIZE_IMPL_HPP_INCLUDED