push_front.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ///////////////////////////////////////////////////////////////////////////////
  2. /// \file push_front.hpp
  3. /// Proto callables Fusion push_front
  4. //
  5. // Copyright 2010 Eric Niebler. Distributed under the Boost
  6. // Software License, Version 1.0. (See accompanying file
  7. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef BOOST_PROTO_FUNCTIONAL_FUSION_PUSH_FRONT_HPP_EAN_11_27_2010
  9. #define BOOST_PROTO_FUNCTIONAL_FUSION_PUSH_FRONT_HPP_EAN_11_27_2010
  10. #include <boost/type_traits/add_const.hpp>
  11. #include <boost/type_traits/remove_const.hpp>
  12. #include <boost/type_traits/remove_reference.hpp>
  13. #include <boost/fusion/include/push_front.hpp>
  14. #include <boost/proto/proto_fwd.hpp>
  15. namespace boost { namespace proto { namespace functional
  16. {
  17. /// \brief A PolymorphicFunctionObject type that invokes the
  18. /// \c fusion::push_front() algorithm on its argument.
  19. ///
  20. /// A PolymorphicFunctionObject type that invokes the
  21. /// \c fusion::push_front() algorithm on its argument.
  22. struct push_front
  23. {
  24. BOOST_PROTO_CALLABLE()
  25. template<typename Sig>
  26. struct result;
  27. template<typename This, typename Seq, typename T>
  28. struct result<This(Seq, T)>
  29. : fusion::result_of::push_front<
  30. typename boost::add_const<typename boost::remove_reference<Seq>::type>::type
  31. , typename boost::remove_const<typename boost::remove_reference<T>::type>::type
  32. >
  33. {};
  34. template<typename Seq, typename T>
  35. typename fusion::result_of::push_front<Seq const, T>::type
  36. operator ()(Seq const &seq, T const &t) const
  37. {
  38. return fusion::push_front(seq, t);
  39. }
  40. };
  41. }}}
  42. #endif