lazy.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. ///////////////////////////////////////////////////////////////////////////////
  2. /// \file lazy.hpp
  3. /// Contains definition of the lazy<> transform.
  4. //
  5. // Copyright 2008 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_TRANSFORM_LAZY_HPP_EAN_12_02_2007
  9. #define BOOST_PROTO_TRANSFORM_LAZY_HPP_EAN_12_02_2007
  10. #include <boost/preprocessor/iteration/iterate.hpp>
  11. #include <boost/preprocessor/repetition/enum_params.hpp>
  12. #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
  13. #include <boost/proto/proto_fwd.hpp>
  14. #include <boost/proto/transform/make.hpp>
  15. #include <boost/proto/transform/call.hpp>
  16. #include <boost/proto/transform/impl.hpp>
  17. #include <boost/proto/transform/detail/pack.hpp>
  18. namespace boost { namespace proto
  19. {
  20. /// \brief A PrimitiveTransform that uses <tt>make\<\></tt> to build
  21. /// a CallableTransform, and then uses <tt>call\<\></tt> to apply it.
  22. ///
  23. /// <tt>lazy\<\></tt> is useful as a higher-order transform, when the
  24. /// transform to be applied depends on the current state of the
  25. /// transformation. The invocation of the <tt>make\<\></tt> transform
  26. /// evaluates any nested transforms, and the resulting type is treated
  27. /// as a CallableTransform, which is evaluated with <tt>call\<\></tt>.
  28. template<typename Object>
  29. struct lazy : transform<lazy<Object> >
  30. {
  31. template<typename Expr, typename State, typename Data>
  32. struct impl
  33. : call<
  34. typename make<Object>::template impl<Expr, State, Data>::result_type
  35. >::template impl<Expr, State, Data>
  36. {};
  37. };
  38. /// INTERNAL ONLY
  39. template<typename Fun>
  40. struct lazy<detail::msvc_fun_workaround<Fun> >
  41. : lazy<Fun>
  42. {};
  43. #include <boost/proto/transform/detail/lazy.hpp>
  44. /// INTERNAL ONLY
  45. ///
  46. template<typename Object>
  47. struct is_callable<lazy<Object> >
  48. : mpl::true_
  49. {};
  50. }}
  51. #endif