Chris@16
|
1 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 /// \file integral_c.hpp
|
Chris@16
|
3 /// Contains definition of the integral_c transform and friends.
|
Chris@16
|
4 //
|
Chris@16
|
5 // Copyright 2011 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_INTEGRAL_C_HPP_EAN_04_28_2011
|
Chris@16
|
10 #define BOOST_PROTO_TRANSFORM_INTEGRAL_C_HPP_EAN_04_28_2011
|
Chris@16
|
11
|
Chris@16
|
12 #include <boost/proto/proto_fwd.hpp>
|
Chris@16
|
13 #include <boost/proto/transform/impl.hpp>
|
Chris@16
|
14
|
Chris@16
|
15 namespace boost { namespace proto
|
Chris@16
|
16 {
|
Chris@16
|
17
|
Chris@16
|
18 /// \brief A PrimitiveTransform that returns a specified
|
Chris@16
|
19 /// integral constant
|
Chris@16
|
20 ///
|
Chris@16
|
21 template<typename T, T I>
|
Chris@16
|
22 struct integral_c : transform<integral_c<T, I> >
|
Chris@16
|
23 {
|
Chris@16
|
24 template<typename Expr, typename State, typename Data>
|
Chris@16
|
25 struct impl : transform_impl<Expr, State, Data>
|
Chris@16
|
26 {
|
Chris@16
|
27 typedef T result_type;
|
Chris@16
|
28
|
Chris@16
|
29 /// \return \c I
|
Chris@16
|
30 /// \throw nothrow
|
Chris@16
|
31 T operator()(
|
Chris@16
|
32 typename impl::expr_param
|
Chris@16
|
33 , typename impl::state_param
|
Chris@16
|
34 , typename impl::data_param
|
Chris@16
|
35 ) const
|
Chris@16
|
36 {
|
Chris@16
|
37 return I;
|
Chris@16
|
38 }
|
Chris@16
|
39 };
|
Chris@16
|
40 };
|
Chris@16
|
41
|
Chris@16
|
42 /// \brief A PrimitiveTransform that returns a specified
|
Chris@16
|
43 /// char
|
Chris@16
|
44 ///
|
Chris@16
|
45 template<char I>
|
Chris@16
|
46 struct char_
|
Chris@16
|
47 : integral_c<char, I>
|
Chris@16
|
48 {};
|
Chris@16
|
49
|
Chris@16
|
50 /// \brief A PrimitiveTransform that returns a specified
|
Chris@16
|
51 /// int
|
Chris@16
|
52 ///
|
Chris@16
|
53 template<int I>
|
Chris@16
|
54 struct int_
|
Chris@16
|
55 : integral_c<int, I>
|
Chris@16
|
56 {};
|
Chris@16
|
57
|
Chris@16
|
58 /// \brief A PrimitiveTransform that returns a specified
|
Chris@16
|
59 /// long
|
Chris@16
|
60 ///
|
Chris@16
|
61 template<long I>
|
Chris@16
|
62 struct long_
|
Chris@16
|
63 : integral_c<long, I>
|
Chris@16
|
64 {};
|
Chris@16
|
65
|
Chris@16
|
66 /// \brief A PrimitiveTransform that returns a specified
|
Chris@16
|
67 /// std::size_t
|
Chris@16
|
68 ///
|
Chris@16
|
69 template<std::size_t I>
|
Chris@16
|
70 struct size_t
|
Chris@16
|
71 : integral_c<std::size_t, I>
|
Chris@16
|
72 {};
|
Chris@16
|
73
|
Chris@16
|
74 /// INTERNAL ONLY
|
Chris@16
|
75 ///
|
Chris@16
|
76 template<typename T, T I>
|
Chris@16
|
77 struct is_callable<integral_c<T, I> >
|
Chris@16
|
78 : mpl::true_
|
Chris@16
|
79 {};
|
Chris@16
|
80
|
Chris@16
|
81 /// INTERNAL ONLY
|
Chris@16
|
82 ///
|
Chris@16
|
83 template<char I>
|
Chris@16
|
84 struct is_callable<char_<I> >
|
Chris@16
|
85 : mpl::true_
|
Chris@16
|
86 {};
|
Chris@16
|
87
|
Chris@16
|
88 /// INTERNAL ONLY
|
Chris@16
|
89 ///
|
Chris@16
|
90 template<int I>
|
Chris@16
|
91 struct is_callable<int_<I> >
|
Chris@16
|
92 : mpl::true_
|
Chris@16
|
93 {};
|
Chris@16
|
94
|
Chris@16
|
95 /// INTERNAL ONLY
|
Chris@16
|
96 ///
|
Chris@16
|
97 template<long I>
|
Chris@16
|
98 struct is_callable<long_<I> >
|
Chris@16
|
99 : mpl::true_
|
Chris@16
|
100 {};
|
Chris@16
|
101
|
Chris@16
|
102 /// INTERNAL ONLY
|
Chris@16
|
103 ///
|
Chris@16
|
104 template<std::size_t I>
|
Chris@16
|
105 struct is_callable<size_t<I> >
|
Chris@16
|
106 : mpl::true_
|
Chris@16
|
107 {};
|
Chris@16
|
108
|
Chris@16
|
109 }}
|
Chris@16
|
110
|
Chris@16
|
111 #endif
|