push_back_impl.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef BOOST_MPL_AUX_PUSH_BACK_IMPL_HPP_INCLUDED
  2. #define BOOST_MPL_AUX_PUSH_BACK_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_back_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_back_arg {};
  22. // agurt 05/feb/04: no default implementation; the stub definition is needed
  23. // to enable the default 'has_push_back' implementation below
  24. template< typename Tag >
  25. struct push_back_impl
  26. {
  27. template< typename Sequence, typename T > struct apply
  28. {
  29. // should be instantiated only in the context of 'has_push_back_impl';
  30. // if you've got an assert here, you are requesting a 'push_back'
  31. // specialization that doesn't exist.
  32. BOOST_MPL_ASSERT_MSG(
  33. ( boost::is_same< T, has_push_back_arg >::value )
  34. , REQUESTED_PUSH_BACK_SPECIALIZATION_FOR_SEQUENCE_DOES_NOT_EXIST
  35. , ( Sequence )
  36. );
  37. };
  38. };
  39. template< typename Tag >
  40. struct has_push_back_impl
  41. {
  42. template< typename Seq > struct apply
  43. #if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING)
  44. : aux::has_type< push_back< Seq, has_push_back_arg > >
  45. {
  46. #else
  47. {
  48. typedef aux::has_type< push_back< Seq, has_push_back_arg > > type;
  49. BOOST_STATIC_CONSTANT(bool, value =
  50. (aux::has_type< push_back< Seq, has_push_back_arg > >::value)
  51. );
  52. #endif
  53. };
  54. };
  55. BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(2, push_back_impl)
  56. BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(1, has_push_back_impl)
  57. }}
  58. #endif // BOOST_MPL_AUX_PUSH_BACK_IMPL_HPP_INCLUDED