push_front_impl.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef BOOST_MPL_AUX_PUSH_FRONT_IMPL_HPP_INCLUDED
  2. #define BOOST_MPL_AUX_PUSH_FRONT_IMPL_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2000-2008
  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/push_front_fwd.hpp>
  14. #include <boost/mpl/assert.hpp>
  15. #include <boost/mpl/aux_/has_type.hpp>
  16. #include <boost/mpl/aux_/traits_lambda_spec.hpp>
  17. #include <boost/mpl/aux_/config/forwarding.hpp>
  18. #include <boost/mpl/aux_/config/static_constant.hpp>
  19. #include <boost/type_traits/is_same.hpp>
  20. namespace boost { namespace mpl {
  21. struct has_push_front_arg {};
  22. // agurt 05/feb/04: no default implementation; the stub definition is needed
  23. // to enable the default 'has_push_front' implementation below
  24. template< typename Tag >
  25. struct push_front_impl
  26. {
  27. template< typename Sequence, typename T > struct apply
  28. {
  29. // should be instantiated only in the context of 'has_push_front_impl';
  30. // if you've got an assert here, you are requesting a 'push_front'
  31. // specialization that doesn't exist.
  32. BOOST_MPL_ASSERT_MSG(
  33. ( boost::is_same< T, has_push_front_arg >::value )
  34. , REQUESTED_PUSH_FRONT_SPECIALIZATION_FOR_SEQUENCE_DOES_NOT_EXIST
  35. , ( Sequence )
  36. );
  37. };
  38. };
  39. template< typename Tag >
  40. struct has_push_front_impl
  41. {
  42. template< typename Seq > struct apply
  43. #if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING)
  44. : aux::has_type< push_front< Seq, has_push_front_arg > >
  45. {
  46. #else
  47. {
  48. typedef aux::has_type< push_front< Seq, has_push_front_arg > > type;
  49. BOOST_STATIC_CONSTANT(bool, value =
  50. (aux::has_type< push_front< Seq, has_push_front_arg > >::value)
  51. );
  52. #endif
  53. };
  54. };
  55. BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(2, push_front_impl)
  56. BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(1, has_push_front_impl)
  57. }}
  58. #endif // BOOST_MPL_AUX_PUSH_FRONT_IMPL_HPP_INCLUDED