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