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 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882
|
[/==============================================================================
Copyright (C) 2001-2007 Joel de Guzman, Dan Marsden, Tobias Schwinger
Use, modification and distribution is subject to 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)
===============================================================================/]
[section Iterator]
Like __mpl__ and __stl__, iterators are a fundamental concept in Fusion.
As with __mpl__ and __stl__ iterators describe positions, and
provide access to data within an underlying __sequence__.
[heading Header]
#include <boost/fusion/iterator.hpp>
#include <boost/fusion/include/iterator.hpp>
[section Concepts]
Fusion iterators are divided into different traversal categories.
__forward_iterator__ is the most basic concept. __bidirectional_iterator__
is a refinement of __forward_iterator__. __random_access_iterator__ is a
refinement of __bidirectional_iterator__.
[section Forward Iterator]
[heading Description]
A Forward Iterator traverses a __sequence__ allowing movement in only one direction through
it's elements, one element at a time.
[variablelist Notation
[[`i`, `j`] [Forward Iterators]]
[[`I`, `J`] [Forward Iterator types]]
[[`M`] [An __mpl__ integral constant]]
[[`N`] [An integral constant]]
]
[heading Expression requirements]
A type models Forward Iterator if, in addition to being CopyConstructable,
the following expressions are valid:
[table
[[Expression] [Return type] [Runtime Complexity]]
[[`__next__(i)`] [__forward_iterator__] [Constant]]
[[`i == j`] [Convertible to bool] [Constant]]
[[`i != j`] [Convertible to bool] [Constant]]
[[`__advance_c__<N>(i)`] [__forward_iterator__] [Constant]]
[[`__advance__<M>(i)`] [__forward_iterator__] [Constant]]
[[`__distance__(i, j)`] [`__result_of_distance__<I, J>::type`][Constant]]
[[`__deref__(i)`] [`__result_of_deref__<I>::type`] [Constant]]
[[`*i`] [`__result_of_deref__<I>::type`] [Constant]]
]
[heading Meta Expressions]
[table
[[Expression] [Compile Time Complexity]]
[[`__result_of_next__<I>::type`] [Amortized constant time]]
[[`__result_of_equal_to__<I, J>::type`] [Amortized constant time]]
[[`__result_of_advance_c__<I, N>::type`] [Linear]]
[[`__result_of_advance__<I ,M>::type`] [Linear]]
[[`__result_of_distance__<I ,J>::type`] [Linear]]
[[`__result_of_deref__<I>::type`] [Amortized constant time]]
[[`__result_of_value_of__<I>::type`] [Amortized constant time]]
]
[heading Expression Semantics]
[
table
[[Expression] [Semantics]]
[[`__next__(i)`] [An iterator to the element following `i`]]
[[`i == j`] [Iterator equality comparison]]
[[`i != j`] [Iterator inequality comparison]]
[[`__advance_c__<N>(i)`] [An iterator n elements after `i` in the sequence]]
[[`__advance__<M>(i)`] [Equivalent to `advance_c<M::value>(i)`]]
[[`__distance__(i, j)`] [The number of elements between `i` and `j`]]
[[`__deref__(i)`] [The element at position`i`]]
[[`*i`] [Equivalent to `deref(i)`]]
]
[heading Invariants]
The following invariants always hold:
* `!(i == j) == (i != j)`
* `__next__(i) == __advance_c__<1>(i)`
* `__distance__(i, __advance_c__<N>(i)) == N`
* Using `__next__` to traverse the sequence will never return to a previously seen position
* `__deref__(i)` is equivalent to `*i`
* If `i == j` then `*i` is equivalent to `*j`
[heading Models]
* __std_pair__ iterator
* __boost_array__ iterator
* __vector__ iterator
* __cons__ iterator
* __list__ iterator
* __set__ iterator
* __map__ iterator
* __single_view__ iterator
* __filter_view__ iterator
* __iterator_range__ iterator
* __joint_view__ iterator
* __transform_view__ iterator
* __reverse_view__ iterator
[endsect]
[section Bidirectional Iterator]
[heading Description]
A Bidirectional Iterator traverses a __sequence__ allowing movement in either direction one
element at a time.
[variablelist Notation
[[`i`] [A Bidirectional Iterator]]
[[`I`] [A Bidirectional Iterator type]]
[[`M`] [An __mpl__ integral constant]]
[[`N`] [An integral constant]]
]
[heading Refinement of]
__forward_iterator__
[heading Expression requirements]
In addition to the requirements defined in __forward_iterator__,
the following expressions must be valid:
[table
[[Expression] [Return type] [Runtime Complexity]]
[[`__next__(i)`] [__bidirectional_iterator__] [Constant]]
[[`__prior__(i)`] [__bidirectional_iterator__] [Constant]]
[[`__advance_c__<N>(i)`] [__bidirectional_iterator__] [Constant]]
[[`__advance__<M>(i)`] [__bidirectional_iterator__] [Constant]]
]
[heading Meta Expressions]
[table
[[Expression] [Compile Time Complexity]]
[[`__result_of_prior__<I>::type`] [Amortized constant time]]
]
[heading Expression Semantics]
The semantics of an expression are defined only where they differ from, or are not defined
in __forward_iterator__
[table
[[Expression] [Semantics]]
[[`__prior__(i)`] [An iterator to the element preceding `i`]]
]
[heading Invariants]
In addition to the invariants of __forward_iterator__,
the following invariants always hold:
* `__prior__(__next__(i)) == i && __prior__(__next__(i)) == __next__(__prior__(i))`
* `__prior__(i) == __advance_c__<-1>(i)`
* Using `__prior__` to traverse a sequence will never return a previously seen position
[heading Models]
* __std_pair__ iterator
* __boost_array__ iterator
* __vector__ iterator
* __iterator_range__ (where adapted sequence is a __bidirectional_sequence__)
* __transform_view__ (where adapted sequence is a __bidirectional_sequence__)
* __reverse_view__
[endsect]
[section Random Access Iterator]
[heading Description]
A Random Access Iterator traverses a __sequence__ moving in either direction,
permitting efficient arbitrary distance movements back and forward through the
sequence.
[variablelist Notation
[[`i`, `j`] [Random Access Iterators]]
[[`I`, `J`] [Random Access Iterator types]]
[[`M`] [An __mpl__ integral constant]]
[[`N`] [An integral constant]]
]
[heading Refinement of]
__bidirectional_iterator__
[heading Expression requirements]
In addition to the requirements defined in __bidirectional_iterator__,
the following expressions must be valid:
[table
[[Expression] [Return type] [Runtime Complexity]]
[[`__next__(i)`] [__random_access_iterator__] [Constant]]
[[`__prior__(i)`] [__random_access_iterator__] [Constant]]
[[`__advance_c__<N>(i)`] [__random_access_iterator__] [Constant]]
[[`__advance__<M>(i)`] [__random_access_iterator__] [Constant]]
]
[heading Meta Expressions]
[table
[[Expression] [Compile Time Complexity]]
[[`__result_of_advance_c__<I, N>::type`] [Amortized constant time]]
[[`__result_of_advance__<I, M>::type`] [Amortized constant time]]
[[`__result_of_distance__<I ,J>::type`] [Amortized constant time]]
]
[heading Models]
* __vector__ iterator
* __std_pair__ iterator
* __boost_array__ iterator
* __iterator_range__ iterator (where adapted sequence is a __random_access_sequence__)
* __transform_view__ iterator (where adapted sequence is a __random_access_sequence__)
* __reverse_view__ iterator (where adapted sequence is a __random_access_sequence__)
[endsect]
[endsect]
[section Functions]
Fusion provides functions for manipulating iterators, analogous to the similar functions
from the __mpl__ library.
[section deref]
[heading Description]
Deferences an iterator.
[heading Synopsis]
template<
typename I
>
typename __result_of_deref__<I>::type deref(I const& i);
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`i`] [Model of __forward_iterator__] [Operation's argument]]
]
[heading Expression Semantics]
__deref__(i);
[*Return type]: `__result_of_deref__<I>::type`
[*Semantics]: Dereferences the iterator `i`.
[heading Header]
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/include/deref.hpp>
[heading Example]
typedef __vector__<int,int&> vec;
int i(0);
vec v(1,i);
assert(__deref__(__begin__(v)) == 1);
assert(__deref__(__next__(__begin__(v))) == 0);
assert(&(__deref__(__next__(__begin__(v)))) == &i);
[endsect]
[section next]
[heading Description]
Moves an iterator 1 position forwards.
[heading Synopsis]
template<
typename I
>
typename __result_of_next__<I>::type next(I const& i);
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`i`] [Model of __forward_iterator__] [Operation's argument]]
]
[heading Expression Semantics]
next(i);
[*Return type]: A model of the same iterator concept as `i`.
[*Semantics]: Returns an iterator to the next element after `i`.
[heading Header]
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/include/next.hpp>
[heading Example]
typedef __vector__<int,int,int> vec;
vec v(1,2,3);
assert(__deref__(__begin__(v)) == 1);
assert(__deref__(__next__(__begin__(v))) == 2);
assert(__deref__(__next__(__next__(__begin__(v)))) == 3);
[endsect]
[section prior]
[heading Description]
Moves an iterator 1 position backwards.
[heading Synopsis]
template<
typename I
>
typename __result_of_prior__<I>::type prior(I const& i);
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`i`] [Model of __bidirectional_iterator__] [Operation's argument]]
]
[heading Expression Semantics]
__prior__(i);
[*Return type]: A model of the same iterator concept as `i`.
[*Semantics]: Returns an iterator to the element prior to `i`.
[heading Header]
#include <boost/fusion/iterator/prior.hpp>
#include <boost/fusion/include/prior.hpp>
[heading Example]
typedef __vector__<int,int> vec;
vec v(1,2);
assert(__deref__(__next__(__begin__(v))) == 2);
assert(__deref__(__prior__(__next__(__begin__(v)))) == 1);
[endsect]
[section distance]
[heading Description]
Returns the distance between 2 iterators.
[heading Synopsis]
template<
typename I,
typename J
>
typename __result_of_distance__<I, J>::type distance(I const& i, J const& j);
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`i`, `j`] [Models of __forward_iterator__ into the same sequence] [The start and end points of the distance to be measured]]
]
[heading Expression Semantics]
__distance__(i,j);
[*Return type]: `int`
[*Semantics]: Returns the distance between iterators `i` and `j`.
[heading Header]
#include <boost/fusion/iterator/distance.hpp>
#include <boost/fusion/include/distance.hpp>
[heading Example]
typedef __vector__<int,int,int> vec;
vec v(1,2,3);
assert(__distance__(__begin__(v), __next__(__next__(__begin__(v)))) == 2);
[endsect]
[section advance]
[heading Description]
Moves an iterator by a specified distance.
[heading Synopsis]
template<
typename I,
typename M
>
typename __result_of_advance__<I, M>::type advance(I const& i);
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`i`] [Model of __forward_iterator__] [Iterator to move relative to]]
[[`N`] [An __mpl_integral_constant__] [Number of positions to move]]
]
[heading Expression Semantics]
__advance__<M>(i);
[*Return type]: A model of the same iterator concept as `i`.
[*Semantics]: Returns an iterator to the element `M` positions from `i`. If `i` is a __bidirectional_iterator__ then `M` may be negative.
[heading Header]
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/include/advance.hpp>
[heading Example]
typedef __vector__<int,int,int> vec;
vec v(1,2,3);
assert(__deref__(__advance__<mpl::int_<2> >(__begin__(v))) == 3);
[endsect]
[section advance_c]
[heading Description]
Moves an iterator by a specified distance.
[heading Synopsis]
template<
typename I,
int N
>
typename __result_of_advance_c__<I, N>::type advance_c(I const& i);
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`i`] [Model of __forward_iterator__] [Iterator to move relative to]]
[[`N`] [Integer constant] [Number of positions to move]]
]
[heading Expression Semantics]
__advance_c__<N>(i);
[*Return type]: A model of the same iterator concept as `i`.
[*Semantics]: Returns an iterator to the element `N` positions from `i`. If `i` is a __bidirectional_iterator__ then `N` may be negative.
[heading Header]
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/include/advance.hpp>
[heading Example]
typedef __vector__<int,int,int> vec;
vec v(1,2,3);
assert(__deref__(__advance_c__<2>(__begin__(v))) == 3);
[endsect]
[endsect]
[section Operator]
Overloaded operators are provided to provide a more natural syntax for dereferencing iterators, and comparing them for equality.
[section:operator_unary_star Operator *]
[heading Description]
Dereferences an iterator.
[heading Synopsis]
template<
typename I
>
typename __result_of_deref__<I>::type operator*(__unspecified__<I> const& i);
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`i`] [Model of __forward_iterator__] [Operation's argument]]
]
[heading Expression Semantics]
*i
[*Return type]: Equivalent to the return type of `__deref__(i)`.
[*Semantics]: Equivalent to `__deref__(i)`.
[heading Header]
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/include/deref.hpp>
[heading Example]
typedef __vector__<int,int&> vec;
int i(0);
vec v(1,i);
assert(*__begin__(v) == 1);
assert(*__next__(__begin__(v)) == 0);
assert(&(*__next__(__begin__(v))) == &i);
[endsect]
[section:operator_equality Operator ==]
[heading Description]
Compares 2 iterators for equality.
[heading Synopsis]
template<
typename I,
typename J
>
__unspecified__ operator==(I const& i, J const& i);
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`i`, `j`] [Any fusion iterators] [Operation's arguments]]
]
[heading Expression Semantics]
i == j
[*Return type]: Convertible to `bool`.
[*Semantics]: Equivalent to `__result_of_equal_to__<I,J>::value` where `I` and `J` are the types of `i` and `j` respectively.
[heading Header]
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/include/equal_to.hpp>
[endsect]
[section:operator_inequality Operator !=]
[heading Description]
Compares 2 iterators for inequality.
[heading Synopsis]
template<
typename I,
typename J
>
__unspecified__ operator==(I const& i, J const& i);
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`i`, `j`] [Any fusion iterators] [Operation's arguments]]
]
[heading Expression Semantics]
[*Return type]: Convertible to `bool`.
[*Semantics]: Equivalent to `!__result_of_equal_to__<I,J>::value` where `I` and `J` are the types of `i` and `j` respectively.
[heading Header]
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/include/equal_to.hpp>
[endsect]
[endsect]
[section Metafunctions]
[section value_of]
[heading Description]
Returns the type stored at the position of an iterator.
[heading Synopsis]
template<
typename I
>
struct value_of
{
typedef __unspecified__ type;
};
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`I`] [Model of __forward_iterator__] [Operation's argument]]
]
[heading Expression Semantics]
__result_of_value_of__<I>::type
[*Return type]: Any type
[*Semantics]: Returns the type stored in a sequence at iterator position `I`.
[heading Header]
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/include/value_of.hpp>
[heading Example]
typedef __vector__<int,int&,const int&> vec;
typedef __result_of_begin__<vec>::type first;
typedef __result_of_next__<first>::type second;
typedef __result_of_next__<second>::type third;
BOOST_MPL_ASSERT((boost::is_same<__result_of_value_of__<first>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<__result_of_value_of__<second>::type, int&>));
BOOST_MPL_ASSERT((boost::is_same<__result_of_value_of__<third>::type, const int&>));
[endsect]
[section deref]
[heading Description]
Returns the type that will be returned by dereferencing an iterator.
[heading Synposis]
template<
typename I
>
struct deref
{
typedef __unspecified__ type;
};
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`I`] [Model of __forward_iterator__] [Operation's argument]]
]
[heading Expression Semantics]
__result_of_deref__<I>::type
[*Return type]: Any type
[*Semantics]: Returns the result of dereferencing an iterator of type `I`.
[heading Header]
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/include/deref.hpp>
[heading Example]
typedef __vector__<int,int&> vec;
typedef const vec const_vec;
typedef __result_of_begin__<vec>::type first;
typedef __result_of_next__<first>::type second;
typedef __result_of_begin__<const_vec>::type const_first;
typedef __result_of_next__<const_first>::type const_second;
BOOST_MPL_ASSERT((boost::is_same<__result_of_deref__<first>::type, int&>));
BOOST_MPL_ASSERT((boost::is_same<__result_of_deref__<second>::type, int&>));
[endsect]
[section next]
[heading Description]
Returns the type of the next iterator in a sequence.
[heading Synposis]
template<
typename I
>
struct next
{
typedef __unspecified__ type;
};
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`I`] [Model of __forward_iterator__] [Operation's argument]]
]
[heading Expression Semantics]
__result_of_next__<I>::type
[*Return type]: A model of the same iterator concept as `I`.
[*Semantics]: Returns an iterator to the next element in the sequence after `I`.
[heading Header]
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/include/next.hpp>
[heading Example]
typedef __vector__<int,double> vec;
typedef __result_of_next__<__result_of_begin__<vec>::type>::type second;
BOOST_MPL_ASSERT((boost::is_same<__result_of_value_of__<second>::type, double>));
[endsect]
[section prior]
[heading Description]
Returns the type of the previous iterator in a sequence.
[heading Synopsis]
template<
typename I
>
struct prior
{
typedef __unspecified__ type;
};
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`I`] [Model of __bidirectional_iterator__] [Operation's argument]]
]
[heading Expression Semantics]
__result_of_prior__<I>::type
[*Return type]: A model of the same iterator concept as `I`.
[*Semantics]: Returns an iterator to the previous element in the sequence before `I`.
[heading Header]
#include <boost/fusion/iterator/prior.hpp>
#include <boost/fusion/include/prior.hpp>
[heading Example]
typedef __vector__<int,double> vec;
typedef __result_of_next__<__result_of_begin__<vec>::type>::type second;
BOOST_MPL_ASSERT((boost::is_same<__result_of_value_of__<second>::type, double>));
typedef __result_of_prior__<second>::type first;
BOOST_MPL_ASSERT((boost::is_same<__result_of_value_of__<first>::type, int>));
[endsect]
[section equal_to]
[heading Description]
Returns a true-valued __mpl_integral_constant__ if `I` and `J` are equal.
[heading Synopsis]
template<
typename I,
typename J
>
struct equal_to
{
typedef __unspecified__ type;
};
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`I`, `J`] [Any fusion iterators] [Operation's arguments]]
]
[heading Expression Semantics]
__result_of_equal_to__<I, J>::type
[*Return type]: A model of __mpl_integral_constant__.
[*Semantics]: Returns `boost::mpl::true_` if `I` and `J` are iterators to the same position. Returns `boost::mpl::false_` otherwise.
[heading Header]
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/include/equal_to.hpp>
[heading Example]
typedef __vector__<int,double> vec;
typedef __result_of_begin__<vec>::type first;
typedef __result_of_end__<vec>::type last;
BOOST_MPL_ASSERT((__result_of_equal_to__<first, first>));
BOOST_MPL_ASSERT_NOT((__result_of_equal_to__<first,last>));
[endsect]
[section distance]
[heading Description]
Returns the distance between two iterators.
[heading Synopsis]
template<
typename I,
typename J
>
struct distance
{
typedef __unspecified__ type;
};
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`I`, `J`] [Models of __forward_iterator__ into the same sequence] [The start and end points of the distance to be measured]]
]
[heading Expression Semantics]
__result_of_distance__<I, J>::type
[*Return type]: A model of __mpl_integral_constant__.
[*Semantics]: Returns the distance between iterators of types `I` and `J`.
[heading Header]
#include <boost/fusion/iterator/distance.hpp>
#include <boost/fusion/include/distance.hpp>
[heading Example]
typedef __vector__<int,double,char> vec;
typedef __result_of_begin__<vec>::type first;
typedef __result_of_next__<first>::type second;
typedef __result_of_next__<second>::type third;
typedef __result_of_distance__<first,third>::type dist;
BOOST_MPL_ASSERT_RELATION(dist::value, ==, 2);
[endsect]
[section advance]
[heading Description]
Moves an iterator a specified distance.
[heading Synopsis]
template<
typename I,
typename M
>
struct advance
{
typedef __unspecified__ type;
};
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`I`] [Model of __forward_iterator__] [Iterator to move relative to]]
[[`M`] [Model of __mpl_integral_constant__] [Number of positions to move]]
]
[heading Expression Semantics]
__result_of_advance__<I,M>::type
[*Return type]: A model of the same iterator concept as `I`.
[*Semantics]: Returns an iterator a distance `M` from `I`. If `I` is a __bidirectional_iterator__ then `M` may be negative.
[heading Header]
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/include/advance.hpp>
[heading Example]
typedef __vector__<int,double,char> vec;
typedef __result_of_begin__<vec>::type first;
typedef __result_of_next__<first>::type second;
typedef __result_of_next__<second>::type third;
BOOST_MPL_ASSERT((__result_of_equal_to__<__result_of_advance__<first, boost::mpl::int_<2> >::type, third>));
[endsect]
[section advance_c]
[heading Description]
Moves an iterator by a specified distance.
[heading Synopsis]
template<
typename I,
int N
>
struct advance_c
{
typedef __unspecified__ type;
};
[table Parameters
[[Parameter] [Requirement] [Description]]
[[`I`] [Model of __forward_iterator__] [Iterator to move relative to]]
[[`N`] [Integer constant] [Number of positions to move]]
]
[heading Expression Semantics]
__result_of_advance_c__<I, N>::type
[*Return type]: A model of the same iterator concept as `I`.
[*Semantics]: Returns an iterator a distance `N` from `I`. If `I` is a __bidirectional_iterator__ then `N` may be negative. Equivalent to `__result_of_advance__<I, boost::mpl::int_<N> >::type`.
[heading Header]
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/include/advance.hpp>
[heading Example]
typedef __vector__<int,double,char> vec;
typedef __result_of_begin__<vec>::type first;
typedef __result_of_next__<first>::type second;
typedef __result_of_next__<second>::type third;
BOOST_MPL_ASSERT((__result_of_equal_to__<__result_of_advance_c__<first, 2>::type, third>));
[endsect]
[endsect]
[endsect]
|