/usr/include/boost/proto/fusion.hpp is in libboost1.62-dev 1.62.0+dfsg-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 | ///////////////////////////////////////////////////////////////////////////////
/// \file fusion.hpp
/// Make any Proto expression a valid Fusion sequence
//
// Copyright 2008 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PROTO_FUSION_HPP_EAN_11_04_2006
#define BOOST_PROTO_FUSION_HPP_EAN_11_04_2006
#include <boost/config.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/long.hpp>
#include <boost/mpl/sequence_tag_fwd.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/fusion/include/is_view.hpp>
#include <boost/fusion/include/tag_of_fwd.hpp>
#include <boost/fusion/include/category_of.hpp>
#include <boost/fusion/include/iterator_base.hpp>
#include <boost/fusion/include/intrinsic.hpp>
#include <boost/fusion/include/single_view.hpp>
#include <boost/fusion/include/transform.hpp>
#include <boost/fusion/include/as_list.hpp>
#include <boost/fusion/include/is_segmented.hpp>
#include <boost/fusion/sequence/comparison/enable_comparison.hpp>
#include <boost/proto/proto_fwd.hpp>
#include <boost/proto/traits.hpp>
#include <boost/proto/eval.hpp>
#include <boost/proto/make_expr.hpp>
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable : 4510) // default constructor could not be generated
#pragma warning(disable : 4512) // assignment operator could not be generated
#pragma warning(disable : 4610) // can never be instantiated - user defined constructor required
#endif
namespace boost { namespace proto
{
namespace detail
{
template<typename Expr, long Pos>
struct expr_iterator
: fusion::iterator_base<expr_iterator<Expr, Pos> >
{
typedef Expr expr_type;
static const long index = Pos;
typedef fusion::random_access_traversal_tag category;
typedef
tag::proto_expr_iterator<
typename Expr::proto_tag
, typename Expr::proto_domain
>
fusion_tag;
explicit expr_iterator(Expr &e)
: expr(e)
{}
Expr &expr;
};
template<typename Tag>
struct as_element
{
template<typename Sig>
struct result;
template<typename This, typename Expr>
struct result<This(Expr)>
: result<This(Expr const &)>
{};
template<typename This, typename Expr>
struct result<This(Expr &)>
: mpl::if_c<
is_same<Tag, typename Expr::proto_tag>::value
, flat_view<Expr>
, fusion::single_view<Expr &>
>
{};
template<typename Expr>
typename result<as_element(Expr &)>::type const
operator ()(Expr &e) const
{
return typename result<as_element(Expr &)>::type(e);
}
template<typename Expr>
typename result<as_element(Expr const &)>::type const
operator ()(Expr const &e) const
{
return typename result<as_element(Expr const &)>::type(e);
}
};
template<typename Expr>
struct flat_view
: fusion::sequence_base<flat_view<Expr> >
{
typedef fusion::forward_traversal_tag category;
typedef
tag::proto_flat_view<
typename Expr::proto_tag
, typename Expr::proto_domain
>
fusion_tag;
typedef
typename fusion::result_of::as_list<
typename fusion::result_of::transform<
Expr
, as_element<typename Expr::proto_tag>
>::type
>::type
segments_type;
explicit flat_view(Expr &e)
: segs_(fusion::as_list(fusion::transform(e, as_element<typename Expr::proto_tag>())))
{}
segments_type segs_;
};
}
namespace result_of
{
template<typename Expr>
struct flatten
: flatten<Expr const &>
{};
template<typename Expr>
struct flatten<Expr &>
{
typedef detail::flat_view<Expr> type;
};
}
namespace functional
{
/// \brief A PolymorphicFunctionObject type that returns a "flattened"
/// view of a Proto expression tree.
///
/// A PolymorphicFunctionObject type that returns a "flattened"
/// view of a Proto expression tree. For a tree with a top-most node
/// tag of type \c T, the elements of the flattened sequence are
/// determined by recursing into each child node with the same
/// tag type and returning those nodes of different type. So for
/// instance, the Proto expression tree corresponding to the
/// expression <tt>a | b | c</tt> has a flattened view with elements
/// [a, b, c], even though the tree is grouped as
/// <tt>((a | b) | c)</tt>.
struct flatten
{
BOOST_PROTO_CALLABLE()
template<typename Sig>
struct result;
template<typename This, typename Expr>
struct result<This(Expr)>
: result<This(Expr const &)>
{};
template<typename This, typename Expr>
struct result<This(Expr &)>
{
typedef proto::detail::flat_view<Expr> type;
};
template<typename Expr>
proto::detail::flat_view<Expr> const
operator ()(Expr &e) const
{
return proto::detail::flat_view<Expr>(e);
}
template<typename Expr>
proto::detail::flat_view<Expr const> const
operator ()(Expr const &e) const
{
return proto::detail::flat_view<Expr const>(e);
}
};
}
/// \brief A function that returns a "flattened"
/// view of a Proto expression tree.
///
/// For a tree with a top-most node
/// tag of type \c T, the elements of the flattened sequence are
/// determined by recursing into each child node with the same
/// tag type and returning those nodes of different type. So for
/// instance, the Proto expression tree corresponding to the
/// expression <tt>a | b | c</tt> has a flattened view with elements
/// [a, b, c], even though the tree is grouped as
/// <tt>((a | b) | c)</tt>.
template<typename Expr>
proto::detail::flat_view<Expr> const
flatten(Expr &e)
{
return proto::detail::flat_view<Expr>(e);
}
/// \overload
///
template<typename Expr>
proto::detail::flat_view<Expr const> const
flatten(Expr const &e)
{
return proto::detail::flat_view<Expr const>(e);
}
/// INTERNAL ONLY
///
template<typename Context>
struct eval_fun
: proto::callable
{
explicit eval_fun(Context &ctx)
: ctx_(ctx)
{}
template<typename Sig>
struct result;
template<typename This, typename Expr>
struct result<This(Expr)>
: result<This(Expr const &)>
{};
template<typename This, typename Expr>
struct result<This(Expr &)>
: proto::result_of::eval<Expr, Context>
{};
template<typename Expr>
typename proto::result_of::eval<Expr, Context>::type
operator ()(Expr &e) const
{
return proto::eval(e, this->ctx_);
}
template<typename Expr>
typename proto::result_of::eval<Expr const, Context>::type
operator ()(Expr const &e) const
{
return proto::eval(e, this->ctx_);
}
private:
Context &ctx_;
};
/// INTERNAL ONLY
///
template<typename Context>
struct is_callable<eval_fun<Context> >
: mpl::true_
{};
}}
namespace boost { namespace fusion
{
namespace extension
{
template<typename Tag>
struct is_sequence_impl;
template<typename Tag, typename Domain>
struct is_sequence_impl<proto::tag::proto_flat_view<Tag, Domain> >
{
template<typename Sequence>
struct apply
: mpl::true_
{};
};
template<typename Tag, typename Domain>
struct is_sequence_impl<proto::tag::proto_expr<Tag, Domain> >
{
template<typename Sequence>
struct apply
: mpl::true_
{};
};
template<typename Tag>
struct is_view_impl;
template<typename Tag, typename Domain>
struct is_view_impl<proto::tag::proto_flat_view<Tag, Domain> >
{
template<typename Sequence>
struct apply
: mpl::true_
{};
};
template<typename Tag, typename Domain>
struct is_view_impl<proto::tag::proto_expr<Tag, Domain> >
{
template<typename Sequence>
struct apply
: mpl::false_
{};
};
template<typename Tag>
struct value_of_impl;
template<typename Tag, typename Domain>
struct value_of_impl<proto::tag::proto_expr_iterator<Tag, Domain> >
{
template<
typename Iterator
, long Arity = proto::arity_of<typename Iterator::expr_type>::value
>
struct apply
{
typedef
typename proto::result_of::child_c<
typename Iterator::expr_type
, Iterator::index
>::value_type
type;
};
template<typename Iterator>
struct apply<Iterator, 0>
{
typedef
typename proto::result_of::value<
typename Iterator::expr_type
>::value_type
type;
};
};
template<typename Tag>
struct deref_impl;
template<typename Tag, typename Domain>
struct deref_impl<proto::tag::proto_expr_iterator<Tag, Domain> >
{
template<
typename Iterator
, long Arity = proto::arity_of<typename Iterator::expr_type>::value
>
struct apply
{
typedef
typename proto::result_of::child_c<
typename Iterator::expr_type &
, Iterator::index
>::type
type;
static type call(Iterator const &iter)
{
return proto::child_c<Iterator::index>(iter.expr);
}
};
template<typename Iterator>
struct apply<Iterator, 0>
{
typedef
typename proto::result_of::value<
typename Iterator::expr_type &
>::type
type;
static type call(Iterator const &iter)
{
return proto::value(iter.expr);
}
};
};
template<typename Tag>
struct advance_impl;
template<typename Tag, typename Domain>
struct advance_impl<proto::tag::proto_expr_iterator<Tag, Domain> >
{
template<typename Iterator, typename N>
struct apply
{
typedef
proto::detail::expr_iterator<
typename Iterator::expr_type
, Iterator::index + N::value
>
type;
static type call(Iterator const &iter)
{
return type(iter.expr);
}
};
};
template<typename Tag>
struct distance_impl;
template<typename Tag, typename Domain>
struct distance_impl<proto::tag::proto_expr_iterator<Tag, Domain> >
{
template<typename IteratorFrom, typename IteratorTo>
struct apply
: mpl::long_<IteratorTo::index - IteratorFrom::index>
{};
};
template<typename Tag>
struct next_impl;
template<typename Tag, typename Domain>
struct next_impl<proto::tag::proto_expr_iterator<Tag, Domain> >
{
template<typename Iterator>
struct apply
: advance_impl<proto::tag::proto_expr_iterator<Tag, Domain> >::template apply<Iterator, mpl::long_<1> >
{};
};
template<typename Tag>
struct prior_impl;
template<typename Tag, typename Domain>
struct prior_impl<proto::tag::proto_expr_iterator<Tag, Domain> >
{
template<typename Iterator>
struct apply
: advance_impl<proto::tag::proto_expr_iterator<Tag, Domain> >::template apply<Iterator, mpl::long_<-1> >
{};
};
template<typename Tag>
struct category_of_impl;
template<typename Tag, typename Domain>
struct category_of_impl<proto::tag::proto_expr<Tag, Domain> >
{
template<typename Sequence>
struct apply
{
typedef random_access_traversal_tag type;
};
};
template<typename Tag>
struct size_impl;
template<typename Tag, typename Domain>
struct size_impl<proto::tag::proto_expr<Tag, Domain> >
{
template<typename Sequence>
struct apply
: mpl::long_<0 == Sequence::proto_arity_c ? 1 : Sequence::proto_arity_c>
{};
};
template<typename Tag>
struct begin_impl;
template<typename Tag, typename Domain>
struct begin_impl<proto::tag::proto_expr<Tag, Domain> >
{
template<typename Sequence>
struct apply
{
typedef proto::detail::expr_iterator<Sequence, 0> type;
static type call(Sequence &seq)
{
return type(seq);
}
};
};
template<typename Tag>
struct end_impl;
template<typename Tag, typename Domain>
struct end_impl<proto::tag::proto_expr<Tag, Domain> >
{
template<typename Sequence>
struct apply
{
typedef
proto::detail::expr_iterator<
Sequence
, 0 == Sequence::proto_arity_c ? 1 : Sequence::proto_arity_c
>
type;
static type call(Sequence &seq)
{
return type(seq);
}
};
};
template<typename Tag>
struct value_at_impl;
template<typename Tag, typename Domain>
struct value_at_impl<proto::tag::proto_expr<Tag, Domain> >
{
template<
typename Sequence
, typename Index
, long Arity = proto::arity_of<Sequence>::value
>
struct apply
{
typedef
typename proto::result_of::child_c<
Sequence
, Index::value
>::value_type
type;
};
template<typename Sequence, typename Index>
struct apply<Sequence, Index, 0>
{
typedef
typename proto::result_of::value<
Sequence
>::value_type
type;
};
};
template<typename Tag>
struct at_impl;
template<typename Tag, typename Domain>
struct at_impl<proto::tag::proto_expr<Tag, Domain> >
{
template<
typename Sequence
, typename Index
, long Arity = proto::arity_of<Sequence>::value
>
struct apply
{
typedef
typename proto::result_of::child_c<
Sequence &
, Index::value
>::type
type;
static type call(Sequence &seq)
{
return proto::child_c<Index::value>(seq);
}
};
template<typename Sequence, typename Index>
struct apply<Sequence, Index, 0>
{
typedef
typename proto::result_of::value<
Sequence &
>::type
type;
static type call(Sequence &seq)
{
return proto::value(seq);
}
};
};
template<typename Tag>
struct convert_impl;
template<typename Tag, typename Domain>
struct convert_impl<proto::tag::proto_expr<Tag, Domain> >
{
template<typename Sequence>
struct apply
{
typedef
typename proto::result_of::unpack_expr<
Tag
, Domain
, Sequence
>::type
type;
static type call(Sequence& seq)
{
return proto::unpack_expr<Tag, Domain>(seq);
}
};
};
template<typename Tag, typename Domain>
struct convert_impl<proto::tag::proto_flat_view<Tag, Domain> >
{
template<typename Sequence>
struct apply
{
typedef
typename proto::result_of::unpack_expr<
Tag
, Domain
, Sequence
>::type
type;
static type call(Sequence& seq)
{
return proto::unpack_expr<Tag, Domain>(seq);
}
};
};
template<typename Tag>
struct is_segmented_impl;
template<typename Tag, typename Domain>
struct is_segmented_impl<proto::tag::proto_flat_view<Tag, Domain> >
{
template<typename Iterator>
struct apply
: mpl::true_
{};
};
template<typename Tag>
struct segments_impl;
template<typename Tag, typename Domain>
struct segments_impl<proto::tag::proto_flat_view<Tag, Domain> >
{
template<typename Sequence>
struct apply
{
typedef typename Sequence::segments_type const &type;
static type call(Sequence &sequence)
{
return sequence.segs_;
}
};
};
template<typename Tag, typename Domain>
struct category_of_impl<proto::tag::proto_flat_view<Tag, Domain> >
{
template<typename Sequence>
struct apply
{
typedef forward_traversal_tag type;
};
};
}
namespace traits
{
template<typename Seq1, typename Seq2>
struct enable_equality<
Seq1
, Seq2
, typename enable_if_c<
mpl::or_<
proto::is_expr<Seq1>
, proto::is_expr<Seq2>
>::value
>::type
>
: mpl::false_
{};
template<typename Seq1, typename Seq2>
struct enable_comparison<
Seq1
, Seq2
, typename enable_if_c<
mpl::or_<
proto::is_expr<Seq1>
, proto::is_expr<Seq2>
>::value
>::type
>
: mpl::false_
{};
}
}}
namespace boost { namespace mpl
{
template<typename Tag, typename Args, long Arity>
struct sequence_tag< proto::expr<Tag, Args, Arity> >
{
typedef fusion::fusion_sequence_tag type;
};
template<typename Tag, typename Args, long Arity>
struct sequence_tag< proto::basic_expr<Tag, Args, Arity> >
{
typedef fusion::fusion_sequence_tag type;
};
}}
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
#endif
|