null.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ///////////////////////////////////////////////////////////////////////////////
  2. /// \file null.hpp
  3. /// Definintion of null_context\<\>, an evaluation context for
  4. /// proto::eval() that simply evaluates each child expression, doesn't
  5. /// combine the results at all, and returns void.
  6. //
  7. // Copyright 2008 Eric Niebler. Distributed under the Boost
  8. // Software License, Version 1.0. (See accompanying file
  9. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_PROTO_CONTEXT_NULL_HPP_EAN_06_24_2007
  11. #define BOOST_PROTO_CONTEXT_NULL_HPP_EAN_06_24_2007
  12. #include <boost/preprocessor/iteration/iterate.hpp>
  13. #include <boost/preprocessor/repetition/repeat.hpp>
  14. #include <boost/proto/proto_fwd.hpp>
  15. #include <boost/proto/eval.hpp>
  16. #include <boost/proto/traits.hpp>
  17. namespace boost { namespace proto { namespace context
  18. {
  19. template<
  20. typename Expr
  21. , typename Context
  22. , long Arity // = Expr::proto_arity_c
  23. >
  24. struct null_eval
  25. {};
  26. template<typename Expr, typename Context>
  27. struct null_eval<Expr, Context, 0>
  28. {
  29. typedef void result_type;
  30. void operator()(Expr &, Context &) const
  31. {}
  32. };
  33. // Additional specializations generated by the preprocessor
  34. #include <boost/proto/context/detail/null_eval.hpp>
  35. /// null_context
  36. ///
  37. struct null_context
  38. {
  39. /// null_context::eval
  40. ///
  41. template<typename Expr, typename ThisContext = null_context const>
  42. struct eval
  43. : null_eval<Expr, ThisContext>
  44. {};
  45. };
  46. }}}
  47. #endif