order_impl.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef BOOST_MPL_AUX_ORDER_IMPL_HPP_INCLUDED
  2. #define BOOST_MPL_AUX_ORDER_IMPL_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2003-2004
  4. // Copyright David Abrahams 2003-2004
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. // See http://www.boost.org/libs/mpl for documentation.
  11. // $Id$
  12. // $Date$
  13. // $Revision$
  14. #include <boost/mpl/order_fwd.hpp>
  15. #include <boost/mpl/if.hpp>
  16. #include <boost/mpl/long.hpp>
  17. #include <boost/mpl/has_key.hpp>
  18. #include <boost/mpl/aux_/overload_names.hpp>
  19. #include <boost/mpl/aux_/static_cast.hpp>
  20. #include <boost/mpl/aux_/type_wrapper.hpp>
  21. #include <boost/mpl/aux_/traits_lambda_spec.hpp>
  22. #include <boost/mpl/aux_/config/msvc.hpp>
  23. #include <boost/mpl/aux_/config/static_constant.hpp>
  24. #include <boost/mpl/aux_/config/workaround.hpp>
  25. namespace boost { namespace mpl {
  26. // default implementation; requires 'Seq' to provide corresponding overloads
  27. // of BOOST_MPL_AUX_OVERLOAD_ORDER_BY_KEY
  28. template< typename Seq, typename Key > struct x_order_impl
  29. #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) \
  30. || BOOST_WORKAROUND(__EDG_VERSION__, <= 245)
  31. {
  32. BOOST_STATIC_CONSTANT(long, value =
  33. sizeof( BOOST_MPL_AUX_OVERLOAD_CALL_ORDER_BY_KEY(
  34. Seq
  35. , BOOST_MPL_AUX_STATIC_CAST(aux::type_wrapper<Key>*, 0)
  36. ) )
  37. );
  38. typedef long_<value> type;
  39. #else // ISO98 C++
  40. : long_<
  41. sizeof( BOOST_MPL_AUX_OVERLOAD_CALL_ORDER_BY_KEY(
  42. Seq
  43. , BOOST_MPL_AUX_STATIC_CAST(aux::type_wrapper<Key>*, 0)
  44. ) )
  45. >
  46. {
  47. #endif
  48. };
  49. template< typename Tag >
  50. struct order_impl
  51. {
  52. template< typename Seq, typename Key > struct apply
  53. : if_<
  54. typename has_key_impl<Tag>::template apply<Seq,Key>
  55. , x_order_impl<Seq,Key>
  56. , void_
  57. >::type
  58. {
  59. };
  60. };
  61. BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(2,order_impl)
  62. }}
  63. #endif // BOOST_MPL_AUX_ORDER_IMPL_HPP_INCLUDED