File indexing completed on 2025-01-18 09:39:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #if !defined(BOOST_LAMBDA_CASTS_HPP)
0015 #define BOOST_LAMBDA_CASTS_HPP
0016
0017 #include "boost/lambda/detail/suppress_unused.hpp"
0018 #include "boost/lambda/core.hpp"
0019
0020 #include <typeinfo>
0021
0022 namespace boost {
0023 namespace lambda {
0024
0025 template<class Act, class Args>
0026 struct return_type_N;
0027
0028 template<class T> class cast_action;
0029
0030 template<class T> class static_cast_action;
0031 template<class T> class dynamic_cast_action;
0032 template<class T> class const_cast_action;
0033 template<class T> class reinterpret_cast_action;
0034
0035 class typeid_action;
0036 class sizeof_action;
0037
0038
0039
0040 template<class T> class cast_action<static_cast_action<T> >
0041 {
0042 public:
0043 template<class RET, class Arg1>
0044 static RET apply(Arg1 &a1) {
0045 return static_cast<RET>(a1);
0046 }
0047 };
0048
0049 template<class T> class cast_action<dynamic_cast_action<T> > {
0050 public:
0051 template<class RET, class Arg1>
0052 static RET apply(Arg1 &a1) {
0053 return dynamic_cast<RET>(a1);
0054 }
0055 };
0056
0057 template<class T> class cast_action<const_cast_action<T> > {
0058 public:
0059 template<class RET, class Arg1>
0060 static RET apply(Arg1 &a1) {
0061 return const_cast<RET>(a1);
0062 }
0063 };
0064
0065 template<class T> class cast_action<reinterpret_cast_action<T> > {
0066 public:
0067 template<class RET, class Arg1>
0068 static RET apply(Arg1 &a1) {
0069 return reinterpret_cast<RET>(a1);
0070 }
0071 };
0072
0073
0074 class typeid_action {
0075 public:
0076 template<class RET, class Arg1>
0077 static RET apply(Arg1 &a1) {
0078 detail::suppress_unused_variable_warnings(a1);
0079 return typeid(a1);
0080 }
0081 };
0082
0083
0084 class sizeof_action
0085 {
0086 public:
0087 template<class RET, class Arg1>
0088 static RET apply(Arg1 &a1) {
0089 return sizeof(a1);
0090 }
0091 };
0092
0093
0094
0095
0096 template<template <class> class cast_type, class T, class A>
0097 struct return_type_N<cast_action< cast_type<T> >, A> {
0098 typedef T type;
0099 };
0100
0101
0102 template<class A>
0103 struct return_type_N<typeid_action, A> {
0104 typedef std::type_info const & type;
0105 };
0106
0107
0108
0109 template<class A>
0110 struct return_type_N<sizeof_action, A> {
0111 typedef std::size_t type;
0112 };
0113
0114
0115
0116
0117
0118
0119 template <class T, class Arg1>
0120 inline const lambda_functor<
0121 lambda_functor_base<
0122 action<1, cast_action<static_cast_action<T> > >,
0123 tuple<typename const_copy_argument <const Arg1>::type>
0124 >
0125 >
0126 ll_static_cast(const Arg1& a1) {
0127 return
0128 lambda_functor_base<
0129 action<1, cast_action<static_cast_action<T> > >,
0130 tuple<typename const_copy_argument <const Arg1>::type>
0131 >
0132 ( tuple<typename const_copy_argument <const Arg1>::type>(a1));
0133 }
0134
0135
0136 template <class T, class Arg1>
0137 inline const lambda_functor<
0138 lambda_functor_base<
0139 action<1, cast_action<dynamic_cast_action<T> > >,
0140 tuple<typename const_copy_argument <const Arg1>::type>
0141 >
0142 >
0143 ll_dynamic_cast(const Arg1& a1) {
0144 return
0145 lambda_functor_base<
0146 action<1, cast_action<dynamic_cast_action<T> > >,
0147 tuple<typename const_copy_argument <const Arg1>::type>
0148 >
0149 ( tuple<typename const_copy_argument <const Arg1>::type>(a1));
0150 }
0151
0152
0153 template <class T, class Arg1>
0154 inline const lambda_functor<
0155 lambda_functor_base<
0156 action<1, cast_action<const_cast_action<T> > >,
0157 tuple<typename const_copy_argument <const Arg1>::type>
0158 >
0159 >
0160 ll_const_cast(const Arg1& a1) {
0161 return
0162 lambda_functor_base<
0163 action<1, cast_action<const_cast_action<T> > >,
0164 tuple<typename const_copy_argument <const Arg1>::type>
0165 >
0166 ( tuple<typename const_copy_argument <const Arg1>::type>(a1));
0167 }
0168
0169
0170 template <class T, class Arg1>
0171 inline const lambda_functor<
0172 lambda_functor_base<
0173 action<1, cast_action<reinterpret_cast_action<T> > >,
0174 tuple<typename const_copy_argument <const Arg1>::type>
0175 >
0176 >
0177 ll_reinterpret_cast(const Arg1& a1) {
0178 return
0179 lambda_functor_base<
0180 action<1, cast_action<reinterpret_cast_action<T> > >,
0181 tuple<typename const_copy_argument <const Arg1>::type>
0182 >
0183 ( tuple<typename const_copy_argument <const Arg1>::type>(a1));
0184 }
0185
0186
0187
0188
0189 template <class Arg1>
0190 inline const lambda_functor<
0191 lambda_functor_base<
0192 action<1, typeid_action>,
0193 tuple<typename const_copy_argument <const Arg1>::type>
0194 >
0195 >
0196 ll_typeid(const Arg1& a1) {
0197 return
0198 lambda_functor_base<
0199 action<1, typeid_action>,
0200 tuple<typename const_copy_argument <const Arg1>::type>
0201 >
0202 ( tuple<typename const_copy_argument <const Arg1>::type>(a1));
0203 }
0204
0205
0206
0207 template <class Arg1>
0208 inline const lambda_functor<
0209 lambda_functor_base<
0210 action<1, sizeof_action>,
0211 tuple<lambda_functor<Arg1> >
0212 >
0213 >
0214 ll_sizeof(const lambda_functor<Arg1>& a1) {
0215 return
0216 lambda_functor_base<
0217 action<1, sizeof_action>,
0218 tuple<lambda_functor<Arg1> >
0219 >
0220 ( tuple<lambda_functor<Arg1> >(a1));
0221 }
0222
0223 }
0224 }
0225
0226 #endif