annotate DEPENDENCIES/generic/include/boost/proto/detail/expr.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
Chris@16 2
Chris@16 3 #ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
Chris@16 4 #include <boost/proto/detail/preprocessed/expr_variadic.hpp>
Chris@16 5 #else
Chris@16 6 #include <boost/proto/detail/preprocessed/expr.hpp>
Chris@16 7 #endif
Chris@16 8
Chris@16 9 #elif !defined(BOOST_PP_IS_ITERATING)
Chris@16 10
Chris@16 11 /// INTERNAL ONLY
Chris@16 12 ///
Chris@16 13 #define BOOST_PROTO_CHILD(Z, N, DATA) \
Chris@16 14 typedef BOOST_PP_CAT(Arg, N) BOOST_PP_CAT(proto_child, N); \
Chris@16 15 BOOST_PP_CAT(proto_child, N) BOOST_PP_CAT(child, N); \
Chris@16 16 /**< INTERNAL ONLY */
Chris@16 17
Chris@16 18 /// INTERNAL ONLY
Chris@16 19 ///
Chris@16 20 #define BOOST_PROTO_VOID(Z, N, DATA) \
Chris@16 21 typedef void BOOST_PP_CAT(proto_child, N); \
Chris@16 22 /**< INTERNAL ONLY */
Chris@16 23
Chris@16 24 // Generate variadic versions of expr
Chris@16 25 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
Chris@16 26 #pragma wave option(preserve: 2, line: 0, output: "preprocessed/expr_variadic.hpp")
Chris@16 27 #endif
Chris@16 28
Chris@16 29 ///////////////////////////////////////////////////////////////////////////////
Chris@16 30 /// \file expr_variadic.hpp
Chris@16 31 /// Contains definition of expr\<\> class template.
Chris@16 32 //
Chris@16 33 // Copyright 2008 Eric Niebler. Distributed under the Boost
Chris@16 34 // Software License, Version 1.0. (See accompanying file
Chris@16 35 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 36
Chris@16 37 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
Chris@16 38 #pragma wave option(preserve: 1)
Chris@16 39 #endif
Chris@16 40
Chris@16 41 // The expr<> specializations are actually defined here.
Chris@16 42 #define BOOST_PROTO_DEFINE_TERMINAL
Chris@16 43 #define BOOST_PP_ITERATION_PARAMS_1 \
Chris@16 44 (3, (0, 0, <boost/proto/detail/expr.hpp>))
Chris@16 45 #include BOOST_PP_ITERATE()
Chris@16 46
Chris@16 47 #undef BOOST_PROTO_DEFINE_TERMINAL
Chris@16 48 #define BOOST_PP_ITERATION_PARAMS_1 \
Chris@16 49 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/expr.hpp>))
Chris@16 50 #include BOOST_PP_ITERATE()
Chris@16 51
Chris@16 52 // Generate non-variadic versions of expr
Chris@16 53 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
Chris@16 54 #define BOOST_NO_CXX11_VARIADIC_TEMPLATES
Chris@16 55 #pragma wave option(preserve: 2, line: 0, output: "preprocessed/expr.hpp")
Chris@16 56
Chris@16 57 ///////////////////////////////////////////////////////////////////////////////
Chris@16 58 /// \file expr.hpp
Chris@16 59 /// Contains definition of expr\<\> class template.
Chris@16 60 //
Chris@16 61 // Copyright 2008 Eric Niebler. Distributed under the Boost
Chris@16 62 // Software License, Version 1.0. (See accompanying file
Chris@16 63 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 64
Chris@16 65 #pragma wave option(preserve: 1)
Chris@16 66
Chris@16 67 // The expr<> specializations are actually defined here.
Chris@16 68 #define BOOST_PROTO_DEFINE_TERMINAL
Chris@16 69 #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 0, <boost/proto/detail/expr.hpp>))
Chris@16 70 #include BOOST_PP_ITERATE()
Chris@16 71
Chris@16 72 #undef BOOST_PROTO_DEFINE_TERMINAL
Chris@16 73 #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/expr.hpp>))
Chris@16 74 #include BOOST_PP_ITERATE()
Chris@16 75
Chris@16 76 #pragma wave option(output: null)
Chris@16 77 #undef BOOST_NO_CXX11_VARIADIC_TEMPLATES
Chris@16 78 #endif
Chris@16 79
Chris@16 80 #undef BOOST_PROTO_CHILD
Chris@16 81 #undef BOOST_PROTO_VOID
Chris@16 82
Chris@16 83 #else
Chris@16 84
Chris@16 85 #define ARG_COUNT BOOST_PP_MAX(1, BOOST_PP_ITERATION())
Chris@16 86
Chris@16 87 /// \brief Representation of a node in an expression tree.
Chris@16 88 ///
Chris@16 89 /// \c proto::expr\<\> is a node in an expression template tree. It
Chris@16 90 /// is a container for its child sub-trees. It also serves as
Chris@16 91 /// the terminal nodes of the tree.
Chris@16 92 ///
Chris@16 93 /// \c Tag is type that represents the operation encoded by
Chris@16 94 /// this expression. It is typically one of the structs
Chris@16 95 /// in the \c boost::proto::tag namespace, but it doesn't
Chris@16 96 /// have to be.
Chris@16 97 ///
Chris@16 98 /// \c Args is a type list representing the type of the children
Chris@16 99 /// of this expression. It is an instantiation of one
Chris@16 100 /// of \c proto::list1\<\>, \c proto::list2\<\>, etc. The
Chris@16 101 /// child types must all themselves be either \c expr\<\>
Chris@16 102 /// or <tt>proto::expr\<\>&</tt>. If \c Args is an
Chris@16 103 /// instantiation of \c proto::term\<\> then this
Chris@16 104 /// \c expr\<\> type represents a terminal expression;
Chris@16 105 /// the parameter to the \c proto::term\<\> template
Chris@16 106 /// represents the terminal's value type.
Chris@16 107 ///
Chris@16 108 /// \c Arity is an integral constant representing the number of child
Chris@16 109 /// nodes this node contains. If \c Arity is 0, then this
Chris@16 110 /// node is a terminal.
Chris@16 111 ///
Chris@16 112 /// \c proto::expr\<\> is a valid Fusion random-access sequence, where
Chris@16 113 /// the elements of the sequence are the child expressions.
Chris@16 114 #ifdef BOOST_PROTO_DEFINE_TERMINAL
Chris@16 115 template<typename Tag, typename Arg0>
Chris@16 116 struct expr<Tag, term<Arg0>, 0>
Chris@16 117 #else
Chris@16 118 template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(ARG_COUNT, typename Arg)>
Chris@16 119 struct expr<Tag, BOOST_PP_CAT(list, BOOST_PP_ITERATION())<BOOST_PP_ENUM_PARAMS(ARG_COUNT, Arg)>, BOOST_PP_ITERATION() >
Chris@16 120 #endif
Chris@16 121 {
Chris@16 122 typedef Tag proto_tag;
Chris@16 123 static const long proto_arity_c = BOOST_PP_ITERATION();
Chris@16 124 typedef mpl::long_<BOOST_PP_ITERATION() > proto_arity;
Chris@16 125 typedef expr proto_base_expr;
Chris@16 126 #ifdef BOOST_PROTO_DEFINE_TERMINAL
Chris@16 127 typedef term<Arg0> proto_args;
Chris@16 128 #else
Chris@16 129 typedef BOOST_PP_CAT(list, BOOST_PP_ITERATION())<BOOST_PP_ENUM_PARAMS(ARG_COUNT, Arg)> proto_args;
Chris@16 130 #endif
Chris@16 131 typedef basic_expr<Tag, proto_args, BOOST_PP_ITERATION() > proto_grammar;
Chris@16 132 typedef default_domain proto_domain;
Chris@16 133 typedef default_generator proto_generator;
Chris@16 134 typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag;
Chris@16 135 typedef expr proto_derived_expr;
Chris@16 136 typedef void proto_is_expr_; /**< INTERNAL ONLY */
Chris@16 137
Chris@16 138 BOOST_PP_REPEAT(ARG_COUNT, BOOST_PROTO_CHILD, ~)
Chris@16 139 BOOST_PP_REPEAT_FROM_TO(ARG_COUNT, BOOST_PROTO_MAX_ARITY, BOOST_PROTO_VOID, ~)
Chris@16 140
Chris@16 141 /// \return *this
Chris@16 142 ///
Chris@16 143 BOOST_FORCEINLINE
Chris@16 144 expr const &proto_base() const
Chris@16 145 {
Chris@16 146 return *this;
Chris@16 147 }
Chris@16 148
Chris@16 149 /// \overload
Chris@16 150 ///
Chris@16 151 BOOST_FORCEINLINE
Chris@16 152 expr &proto_base()
Chris@16 153 {
Chris@16 154 return *this;
Chris@16 155 }
Chris@16 156
Chris@16 157 #ifdef BOOST_PROTO_DEFINE_TERMINAL
Chris@16 158 /// \return A new \c expr\<\> object initialized with the specified
Chris@16 159 /// arguments.
Chris@16 160 ///
Chris@16 161 template<typename A0>
Chris@16 162 BOOST_FORCEINLINE
Chris@16 163 static expr const make(A0 &a0)
Chris@16 164 {
Chris@16 165 return detail::make_terminal(a0, static_cast<expr *>(0), static_cast<proto_args *>(0));
Chris@16 166 }
Chris@16 167
Chris@16 168 /// \overload
Chris@16 169 ///
Chris@16 170 template<typename A0>
Chris@16 171 BOOST_FORCEINLINE
Chris@16 172 static expr const make(A0 const &a0)
Chris@16 173 {
Chris@16 174 return detail::make_terminal(a0, static_cast<expr *>(0), static_cast<proto_args *>(0));
Chris@16 175 }
Chris@16 176 #else
Chris@16 177 /// \return A new \c expr\<\> object initialized with the specified
Chris@16 178 /// arguments.
Chris@16 179 ///
Chris@16 180 template<BOOST_PP_ENUM_PARAMS(ARG_COUNT, typename A)>
Chris@16 181 BOOST_FORCEINLINE
Chris@16 182 static expr const make(BOOST_PP_ENUM_BINARY_PARAMS(ARG_COUNT, A, const &a))
Chris@16 183 {
Chris@16 184 expr that = {BOOST_PP_ENUM_PARAMS(ARG_COUNT, a)};
Chris@16 185 return that;
Chris@16 186 }
Chris@16 187 #endif
Chris@16 188
Chris@16 189 #if 1 == BOOST_PP_ITERATION()
Chris@16 190 /// If \c Tag is \c boost::proto::tag::address_of and \c proto_child0 is
Chris@16 191 /// <tt>T&</tt>, then \c address_of_hack_type_ is <tt>T*</tt>.
Chris@16 192 /// Otherwise, it is some undefined type.
Chris@16 193 typedef typename detail::address_of_hack<Tag, proto_child0>::type address_of_hack_type_;
Chris@16 194
Chris@16 195 /// \return The address of <tt>this->child0</tt> if \c Tag is
Chris@16 196 /// \c boost::proto::tag::address_of. Otherwise, this function will
Chris@16 197 /// fail to compile.
Chris@16 198 ///
Chris@16 199 /// \attention Proto overloads <tt>operator&</tt>, which means that
Chris@16 200 /// proto-ified objects cannot have their addresses taken, unless we use
Chris@16 201 /// the following hack to make \c &x implicitly convertible to \c X*.
Chris@16 202 BOOST_FORCEINLINE
Chris@16 203 operator address_of_hack_type_() const
Chris@16 204 {
Chris@16 205 return boost::addressof(this->child0);
Chris@16 206 }
Chris@16 207 #else
Chris@16 208 /// INTERNAL ONLY
Chris@16 209 ///
Chris@16 210 typedef detail::not_a_valid_type address_of_hack_type_;
Chris@16 211 #endif
Chris@16 212
Chris@16 213 /// Assignment
Chris@16 214 ///
Chris@16 215 /// \param a The rhs.
Chris@16 216 /// \return A new \c expr\<\> node representing an assignment of \c that to \c *this.
Chris@16 217 BOOST_FORCEINLINE
Chris@16 218 proto::expr<
Chris@16 219 proto::tag::assign
Chris@16 220 , list2<expr &, expr const &>
Chris@16 221 , 2
Chris@16 222 > const
Chris@16 223 operator =(expr const &a)
Chris@16 224 {
Chris@16 225 proto::expr<
Chris@16 226 proto::tag::assign
Chris@16 227 , list2<expr &, expr const &>
Chris@16 228 , 2
Chris@16 229 > that = {*this, a};
Chris@16 230 return that;
Chris@16 231 }
Chris@16 232
Chris@16 233 /// Assignment
Chris@16 234 ///
Chris@16 235 /// \param a The rhs.
Chris@16 236 /// \return A new \c expr\<\> node representing an assignment of \c a to \c *this.
Chris@16 237 template<typename A>
Chris@16 238 BOOST_FORCEINLINE
Chris@16 239 proto::expr<
Chris@16 240 proto::tag::assign
Chris@16 241 , list2<expr const &, typename result_of::as_child<A>::type>
Chris@16 242 , 2
Chris@16 243 > const
Chris@16 244 operator =(A &a) const
Chris@16 245 {
Chris@16 246 proto::expr<
Chris@16 247 proto::tag::assign
Chris@16 248 , list2<expr const &, typename result_of::as_child<A>::type>
Chris@16 249 , 2
Chris@16 250 > that = {*this, proto::as_child(a)};
Chris@16 251 return that;
Chris@16 252 }
Chris@16 253
Chris@16 254 /// \overload
Chris@16 255 ///
Chris@16 256 template<typename A>
Chris@16 257 BOOST_FORCEINLINE
Chris@16 258 proto::expr<
Chris@16 259 proto::tag::assign
Chris@16 260 , list2<expr const &, typename result_of::as_child<A const>::type>
Chris@16 261 , 2
Chris@16 262 > const
Chris@16 263 operator =(A const &a) const
Chris@16 264 {
Chris@16 265 proto::expr<
Chris@16 266 proto::tag::assign
Chris@16 267 , list2<expr const &, typename result_of::as_child<A const>::type>
Chris@16 268 , 2
Chris@16 269 > that = {*this, proto::as_child(a)};
Chris@16 270 return that;
Chris@16 271 }
Chris@16 272
Chris@16 273 #ifdef BOOST_PROTO_DEFINE_TERMINAL
Chris@16 274 /// \overload
Chris@16 275 ///
Chris@16 276 template<typename A>
Chris@16 277 BOOST_FORCEINLINE
Chris@16 278 proto::expr<
Chris@16 279 proto::tag::assign
Chris@16 280 , list2<expr &, typename result_of::as_child<A>::type>
Chris@16 281 , 2
Chris@16 282 > const
Chris@16 283 operator =(A &a)
Chris@16 284 {
Chris@16 285 proto::expr<
Chris@16 286 proto::tag::assign
Chris@16 287 , list2<expr &, typename result_of::as_child<A>::type>
Chris@16 288 , 2
Chris@16 289 > that = {*this, proto::as_child(a)};
Chris@16 290 return that;
Chris@16 291 }
Chris@16 292
Chris@16 293 /// \overload
Chris@16 294 ///
Chris@16 295 template<typename A>
Chris@16 296 BOOST_FORCEINLINE
Chris@16 297 proto::expr<
Chris@16 298 proto::tag::assign
Chris@16 299 , list2<expr &, typename result_of::as_child<A const>::type>
Chris@16 300 , 2
Chris@16 301 > const
Chris@16 302 operator =(A const &a)
Chris@16 303 {
Chris@16 304 proto::expr<
Chris@16 305 proto::tag::assign
Chris@16 306 , list2<expr &, typename result_of::as_child<A const>::type>
Chris@16 307 , 2
Chris@16 308 > that = {*this, proto::as_child(a)};
Chris@16 309 return that;
Chris@16 310 }
Chris@16 311 #endif
Chris@16 312
Chris@16 313 /// Subscript
Chris@16 314 ///
Chris@16 315 /// \param a The rhs.
Chris@16 316 /// \return A new \c expr\<\> node representing \c *this subscripted with \c a.
Chris@16 317 template<typename A>
Chris@16 318 BOOST_FORCEINLINE
Chris@16 319 proto::expr<
Chris@16 320 proto::tag::subscript
Chris@16 321 , list2<expr const &, typename result_of::as_child<A>::type>
Chris@16 322 , 2
Chris@16 323 > const
Chris@16 324 operator [](A &a) const
Chris@16 325 {
Chris@16 326 proto::expr<
Chris@16 327 proto::tag::subscript
Chris@16 328 , list2<expr const &, typename result_of::as_child<A>::type>
Chris@16 329 , 2
Chris@16 330 > that = {*this, proto::as_child(a)};
Chris@16 331 return that;
Chris@16 332 }
Chris@16 333
Chris@16 334 /// \overload
Chris@16 335 ///
Chris@16 336 template<typename A>
Chris@16 337 BOOST_FORCEINLINE
Chris@16 338 proto::expr<
Chris@16 339 proto::tag::subscript
Chris@16 340 , list2<expr const &, typename result_of::as_child<A const>::type>
Chris@16 341 , 2
Chris@16 342 > const
Chris@16 343 operator [](A const &a) const
Chris@16 344 {
Chris@16 345 proto::expr<
Chris@16 346 proto::tag::subscript
Chris@16 347 , list2<expr const &, typename result_of::as_child<A const>::type>
Chris@16 348 , 2
Chris@16 349 > that = {*this, proto::as_child(a)};
Chris@16 350 return that;
Chris@16 351 }
Chris@16 352
Chris@16 353 #ifdef BOOST_PROTO_DEFINE_TERMINAL
Chris@16 354 /// \overload
Chris@16 355 ///
Chris@16 356 template<typename A>
Chris@16 357 BOOST_FORCEINLINE
Chris@16 358 proto::expr<
Chris@16 359 proto::tag::subscript
Chris@16 360 , list2<expr &, typename result_of::as_child<A>::type>
Chris@16 361 , 2
Chris@16 362 > const
Chris@16 363 operator [](A &a)
Chris@16 364 {
Chris@16 365 proto::expr<
Chris@16 366 proto::tag::subscript
Chris@16 367 , list2<expr &, typename result_of::as_child<A>::type>
Chris@16 368 , 2
Chris@16 369 > that = {*this, proto::as_child(a)};
Chris@16 370 return that;
Chris@16 371 }
Chris@16 372
Chris@16 373 /// \overload
Chris@16 374 ///
Chris@16 375 template<typename A>
Chris@16 376 BOOST_FORCEINLINE
Chris@16 377 proto::expr<
Chris@16 378 proto::tag::subscript
Chris@16 379 , list2<expr &, typename result_of::as_child<A const>::type>
Chris@16 380 , 2
Chris@16 381 > const
Chris@16 382 operator [](A const &a)
Chris@16 383 {
Chris@16 384 proto::expr<
Chris@16 385 proto::tag::subscript
Chris@16 386 , list2<expr &, typename result_of::as_child<A const>::type>
Chris@16 387 , 2
Chris@16 388 > that = {*this, proto::as_child(a)};
Chris@16 389 return that;
Chris@16 390 }
Chris@16 391 #endif
Chris@16 392
Chris@16 393 /// Encodes the return type of \c expr\<\>::operator(), for use with \c boost::result_of\<\>
Chris@16 394 ///
Chris@16 395 template<typename Sig>
Chris@16 396 struct result
Chris@16 397 {
Chris@16 398 typedef typename result_of::funop<Sig, expr, default_domain>::type const type;
Chris@16 399 };
Chris@16 400
Chris@16 401 #ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
Chris@16 402 /// \overload
Chris@16 403 ///
Chris@16 404 template<typename ...A>
Chris@16 405 BOOST_FORCEINLINE
Chris@16 406 typename result_of::funop<
Chris@16 407 expr const(A const &...)
Chris@16 408 , expr
Chris@16 409 , default_domain
Chris@16 410 >::type const
Chris@16 411 operator ()(A const &... a) const
Chris@16 412 {
Chris@16 413 return result_of::funop<
Chris@16 414 expr const(A const &...)
Chris@16 415 , expr
Chris@16 416 , default_domain
Chris@16 417 >::call(*this, a...);
Chris@16 418 }
Chris@16 419
Chris@16 420 #ifdef BOOST_PROTO_DEFINE_TERMINAL
Chris@16 421 /// \overload
Chris@16 422 ///
Chris@16 423 template<typename ...A>
Chris@16 424 BOOST_FORCEINLINE
Chris@16 425 typename result_of::funop<
Chris@16 426 expr(A const &...)
Chris@16 427 , expr
Chris@16 428 , default_domain
Chris@16 429 >::type const
Chris@16 430 operator ()(A const &... a)
Chris@16 431 {
Chris@16 432 return result_of::funop<
Chris@16 433 expr(A const &...)
Chris@16 434 , expr
Chris@16 435 , default_domain
Chris@16 436 >::call(*this, a...);
Chris@16 437 }
Chris@16 438 #endif
Chris@16 439
Chris@16 440 #else // BOOST_NO_CXX11_VARIADIC_TEMPLATES
Chris@16 441
Chris@16 442 /// Function call
Chris@16 443 ///
Chris@16 444 /// \return A new \c expr\<\> node representing the function invocation of \c (*this)().
Chris@16 445 BOOST_FORCEINLINE
Chris@16 446 proto::expr<proto::tag::function, list1<expr const &>, 1> const
Chris@16 447 operator ()() const
Chris@16 448 {
Chris@16 449 proto::expr<proto::tag::function, list1<expr const &>, 1> that = {*this};
Chris@16 450 return that;
Chris@16 451 }
Chris@16 452
Chris@16 453 #ifdef BOOST_PROTO_DEFINE_TERMINAL
Chris@16 454 /// \overload
Chris@16 455 ///
Chris@16 456 BOOST_FORCEINLINE
Chris@16 457 proto::expr<proto::tag::function, list1<expr &>, 1> const
Chris@16 458 operator ()()
Chris@16 459 {
Chris@16 460 proto::expr<proto::tag::function, list1<expr &>, 1> that = {*this};
Chris@16 461 return that;
Chris@16 462 }
Chris@16 463 #endif
Chris@16 464
Chris@16 465 #define BOOST_PP_ITERATION_PARAMS_2 \
Chris@16 466 (3, (1, BOOST_PP_DEC(BOOST_PROTO_MAX_FUNCTION_CALL_ARITY), <boost/proto/detail/expr_funop.hpp>))
Chris@16 467 #include BOOST_PP_ITERATE()
Chris@16 468
Chris@16 469 #endif
Chris@16 470 };
Chris@16 471
Chris@16 472 #undef ARG_COUNT
Chris@16 473
Chris@16 474 #endif