Chris@16
|
1 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 /// \file lazy.hpp
|
Chris@16
|
3 /// Contains definition of the lazy<> transform.
|
Chris@16
|
4 //
|
Chris@16
|
5 // Copyright 2008 Eric Niebler. Distributed under the Boost
|
Chris@16
|
6 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
7 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8
|
Chris@16
|
9 #ifndef BOOST_PROTO_TRANSFORM_LAZY_HPP_EAN_12_02_2007
|
Chris@16
|
10 #define BOOST_PROTO_TRANSFORM_LAZY_HPP_EAN_12_02_2007
|
Chris@16
|
11
|
Chris@16
|
12 #include <boost/preprocessor/iteration/iterate.hpp>
|
Chris@16
|
13 #include <boost/preprocessor/repetition/enum_params.hpp>
|
Chris@16
|
14 #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
|
Chris@16
|
15 #include <boost/proto/proto_fwd.hpp>
|
Chris@16
|
16 #include <boost/proto/transform/make.hpp>
|
Chris@16
|
17 #include <boost/proto/transform/call.hpp>
|
Chris@16
|
18 #include <boost/proto/transform/impl.hpp>
|
Chris@16
|
19 #include <boost/proto/transform/detail/pack.hpp>
|
Chris@16
|
20
|
Chris@16
|
21 namespace boost { namespace proto
|
Chris@16
|
22 {
|
Chris@16
|
23 /// \brief A PrimitiveTransform that uses <tt>make\<\></tt> to build
|
Chris@16
|
24 /// a CallableTransform, and then uses <tt>call\<\></tt> to apply it.
|
Chris@16
|
25 ///
|
Chris@16
|
26 /// <tt>lazy\<\></tt> is useful as a higher-order transform, when the
|
Chris@16
|
27 /// transform to be applied depends on the current state of the
|
Chris@16
|
28 /// transformation. The invocation of the <tt>make\<\></tt> transform
|
Chris@16
|
29 /// evaluates any nested transforms, and the resulting type is treated
|
Chris@16
|
30 /// as a CallableTransform, which is evaluated with <tt>call\<\></tt>.
|
Chris@16
|
31 template<typename Object>
|
Chris@16
|
32 struct lazy : transform<lazy<Object> >
|
Chris@16
|
33 {
|
Chris@16
|
34 template<typename Expr, typename State, typename Data>
|
Chris@16
|
35 struct impl
|
Chris@16
|
36 : call<
|
Chris@16
|
37 typename make<Object>::template impl<Expr, State, Data>::result_type
|
Chris@16
|
38 >::template impl<Expr, State, Data>
|
Chris@16
|
39 {};
|
Chris@16
|
40 };
|
Chris@16
|
41
|
Chris@16
|
42 /// INTERNAL ONLY
|
Chris@16
|
43 template<typename Fun>
|
Chris@16
|
44 struct lazy<detail::msvc_fun_workaround<Fun> >
|
Chris@16
|
45 : lazy<Fun>
|
Chris@16
|
46 {};
|
Chris@16
|
47
|
Chris@16
|
48 #include <boost/proto/transform/detail/lazy.hpp>
|
Chris@16
|
49
|
Chris@16
|
50 /// INTERNAL ONLY
|
Chris@16
|
51 ///
|
Chris@16
|
52 template<typename Object>
|
Chris@16
|
53 struct is_callable<lazy<Object> >
|
Chris@16
|
54 : mpl::true_
|
Chris@16
|
55 {};
|
Chris@16
|
56
|
Chris@16
|
57 }}
|
Chris@16
|
58
|
Chris@16
|
59 #endif
|