1 [/==============================================================================
2 Copyright (C) 2001-2011 Joel de Guzman
3 Copyright (C) 2006 Dan Marsden
4 Copyright (C) 2014 Christoph Weiss
6 Use, modification and distribution is subject to the Boost Software
7 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 http://www.boost.org/LICENSE_1_0.txt)
9 ===============================================================================/]
12 Like __mpl__, the Sequence is a fundamental concept in Fusion. A Sequence
13 may or may not actually store or contain data. __containers__ are sequences
14 that hold data. __views__, on the other hand, are sequences that do not
15 store any data. Instead, they are proxies that impart an alternative
16 presentation over another sequence. All models of Sequence have an
17 associated __iterator__ type that can be used to iterate through the
22 #include <boost/fusion/sequence.hpp>
23 #include <boost/fusion/include/sequence.hpp>
27 Fusion Sequences are organized into a hierarchy of concepts.
31 Fusion's sequence traversal related concepts parallel Fusion's
32 __iterator_concepts__. __forward_sequence__ is the most basic concept.
33 __bidirectional_sequence__ is a refinement of __forward_sequence__.
34 __random_access_sequence__ is a refinement of __bidirectional_sequence__.
35 These concepts pertain to sequence traversal.
37 [heading Associativity]
39 The __associative_sequence__ concept is orthogonal to traversal. An Associative
40 Sequence allows efficient retrieval of elements based on keys.
44 The __unbounded_sequence__ concept is also orthogonal to traversal and associativity.
45 A Unbounded Sequence allows out-of-bounds access.
47 [section Forward Sequence]
51 A Forward Sequence is a Sequence whose elements are arranged in a definite
52 order. The ordering is guaranteed not to change from iteration to
53 iteration. The requirement of a definite ordering allows the definition of
54 element-by-element equality (if the container's element type is Equality
55 Comparable) and of lexicographical ordering (if the container's element
56 type is LessThan Comparable).
58 [variablelist Notation
59 [[`s`] [A Forward Sequence]]
60 [[`S`] [A Forward Sequence type]]
61 [[`o`] [An arbitrary object]]
62 [[`e`] [A Sequence element]]
65 [heading Valid Expressions]
67 For any Forward Sequence the following expressions must be valid:
70 [[Expression] [Return type] [Type Requirements] [Runtime Complexity]]
71 [[`__begin__(s)`] [__forward_iterator__] [] [Constant]]
72 [[`__end__(s)`] [__forward_iterator__] [] [Constant]]
73 [[`__size__(s)`] [__mpl_integral_constant__.
74 Convertible to int.] [] [Constant]]
75 [[`__empty__(s)`] [__mpl_boolean_constant__.
76 Convertible to bool.] [] [Constant]]
77 [[`__front__(s)`] [Any type] [] [Constant]]
78 [[`__front__(s) = o`] [Any type] [`s` is mutable and
82 a valid expression.] [Constant]]
85 [heading Result Type Expressions]
88 [[Expression] [Compile Time Complexity]]
89 [[`__result_of_begin__<S>::type`] [Amortized constant time]]
90 [[`__result_of_end__<S>::type`] [Amortized constant time]]
91 [[`__result_of_size__<S>::type`] [Unspecified]]
92 [[`__result_of_empty__<S>::type`] [Constant time]]
93 [[`__result_of_front__<S>::type`] [Amortized constant time]]
96 [heading Expression Semantics]
99 [[Expression] [Semantics]]
100 [[`__begin__(s)`] [An iterator to the first element of the sequence; see __begin__.]]
101 [[`__end__(s)`] [A past-the-end iterator to the sequence; see __end__.]]
102 [[`__size__(s)`] [The size of the sequence; see __size__.]]
103 [[`__empty__(s)`] [A boolean Integral Constant `c` such that
104 `c::value == true` if and only if the sequence
105 is empty; see __empty__.]]
106 [[`__front__(s)`] [The first element in the sequence; see __front__.]]
111 For any Forward Sequence s the following invariants always hold:
113 * `[__begin__(s), __end__(s))` is always a valid range.
114 * An __algorithm__ that iterates through the range `[__begin__(s), __end__(s))`
115 will pass through every element of `s` exactly once.
116 * `__begin__(s)` is identical to `__end__(s))` if and only if `s` is empty.
117 * Two different iterations through `s` will access its elements in
139 [section Bidirectional Sequence]
141 [heading Description]
143 A Bidirectional Sequence is a __forward_sequence__ whose iterators model
144 __bidirectional_iterator__.
146 [heading Refinement of]
150 [variablelist Notation
151 [[`s`] [A Bidirectional Sequence]]
152 [[`S`] [A Bidirectional Sequence type]]
153 [[`o`] [An arbitrary object]]
154 [[`e`] [A Sequence element]]
157 [heading Valid Expressions]
159 In addition to the requirements defined in __forward_sequence__, for any
160 Bidirectional Sequence the following must be met:
163 [[Expression] [Return type] [Type Requirements] [Runtime Complexity]]
164 [[`__begin__(s)`] [__bidirectional_iterator__] [] [Constant]]
165 [[`__end__(s)`] [__bidirectional_iterator__] [] [Constant]]
166 [[`__back__(s)`] [Any type] [] [Constant]]
167 [[`__back__(s) = o`] [Any type] [`s` is mutable and
171 a valid expression.] [Constant]]
174 [heading Result Type Expressions]
177 [[Expression] [Compile Time Complexity]]
178 [[`__result_of_begin__<S>::type`] [Amortized constant time]]
179 [[`__result_of_end__<S>::type`] [Amortized constant time]]
180 [[`__result_of_back__<S>::type`] [Amortized constant time]]
183 [heading Expression Semantics]
185 The semantics of an expression are defined only where they differ from, or
186 are not defined in __forward_sequence__.
189 [[Expression] [Semantics]]
190 [[`__back__(s)`] [The last element in the sequence; see __back__.]]
201 * __iterator_range__ (where adapted sequence is a Bidirectional Sequence)
202 * __transform_view__ (where adapted sequence is a Bidirectional Sequence)
203 * __zip_view__ (where adapted sequences are models of Bidirectional Sequence)
207 [section Random Access Sequence]
209 [heading Description]
211 A Random Access Sequence is a __bidirectional_sequence__ whose iterators
212 model __random_access_iterator__. It guarantees constant time access to
213 arbitrary sequence elements.
215 [heading Refinement of]
217 __bidirectional_sequence__
219 [variablelist Notation
220 [[`s`] [A Random Access Sequence]]
221 [[`S`] [A Random Access Sequence type]]
222 [[`M`] [An __mpl__ integral constant]]
223 [[`N`] [An integral constant]]
224 [[`o`] [An arbitrary object]]
225 [[`e`] [A Sequence element]]
228 [heading Valid Expressions]
230 In addition to the requirements defined in __bidirectional_sequence__, for
231 any Random Access Sequence the following must be met:
234 [[Expression] [Return type] [Type Requirements] [Runtime Complexity]]
235 [[`__begin__(s)`] [__random_access_iterator__] [] [Constant]]
236 [[`__end__(s)`] [__random_access_iterator__] [] [Constant]]
237 [[`__at_c__<N>(s)`] [Any type] [] [Constant]]
238 [[`__at_c__<N>(s) = o`] [Any type] [`s` is mutable and
242 a valid expression.] [Constant]]
243 [[`__at__<M>(s)`] [Any type] [] [Constant]]
244 [[`__at__<M>(s) = o`] [Any type] [`s` is mutable and
248 a valid expression.] [Constant]]
251 [heading Result Type Expressions]
254 [[Expression] [Compile Time Complexity]]
255 [[`__result_of_begin__<S>::type`] [Amortized constant time]]
256 [[`__result_of_end__<S>::type`] [Amortized constant time]]
257 [[`__result_of_at__<S, M>::type`] [Amortized constant time]]
258 [[`__result_of_at_c__<S, N>::type`] [Amortized constant time]]
259 [[`__result_of_value_at__<S, M>::type`] [Amortized constant time]]
260 [[`__result_of_value_at_c__<S, N>::type`] [Amortized constant time]]
263 [note `__result_of_at__<S, M>` returns the actual type returned by
264 `__at__<M>(s)`. In most cases, this is a reference. Hence, there is no way to
265 know the exact element type using `__result_of_at__<S, M>`.The element at `M`
266 may actually be a reference to begin with. For this purpose, you can use
267 `__result_of_value_at__<S, M>` (Note that, `__result_of_value_at_c__<S, N>`
268 is a counterpart of `__result_of_at_c__<S, N>` as well).]
270 [heading Expression Semantics]
272 The semantics of an expression are defined only where they differ from, or
273 are not defined in __bidirectional_sequence__.
276 [[Expression] [Semantics]]
277 [[`__at__<M>(s)`] [The Mth element from the beginning of the sequence; see __at__.]]
278 [[`__at_c__<N>(s)`] [The Nth element from the beginning of the sequence; see __at_c__.]]
289 * __iterator_range__ (where adapted sequence is a Random Access Sequence)
290 * __transform_view__ (where adapted sequence is a Random Access Sequence)
291 * __zip_view__ (where adapted sequences are models of Random Access Sequence)
295 [section Associative Sequence]
297 [heading Description]
299 An Associative Sequence allows efficient retrieval of elements based on keys.
300 Like associative sequences in __mpl__, and unlike associative containers in
301 __stl__, Fusion associative sequences have no implied ordering relation.
302 Instead, type identity is used to impose an equivalence relation on keys.
303 Keys are not checked for uniqueness.
305 [variablelist Notation
306 [[`s`] [An Associative Sequence]]
307 [[`S`] [An Associative Sequence type]]
308 [[`K`] [An arbitrary /key/ type]]
309 [[`o`] [An arbitrary object]]
310 [[`e`] [A Sequence element]]
313 [heading Valid Expressions]
315 For any Associative Sequence the following expressions must be valid:
318 [[Expression] [Return type] [Type Requirements] [Runtime Complexity]]
319 [[`__has_key__<K>(s)`] [__mpl_boolean_constant__.
320 Convertible to bool.] [] [Constant]]
321 [[`__at_key__<K>(s)`] [Any type] [] [Constant]]
322 [[`__at_key__<K>(s) = o`] [Any type] [`s` is mutable and
326 a valid expression.] [Constant]]
329 [heading Result Type Expressions]
332 [[Expression] [Compile Time Complexity]]
333 [[`__result_of_has_key__<S, K>::type`] [Amortized constant time]]
334 [[`__result_of_at_key__<S, K>::type`] [Amortized constant time]]
335 [[`__result_of_value_at_key__<S, K>::type`] [Amortized constant time]]
338 [note `__result_of_at_key__<S, K>` returns the actual type returned
339 by `__at_key__<K>(s)`. In most cases, this is a reference. Hence, there is no
340 way to know the exact element type using `__result_of_at_key__<S, K>`.The
341 element at `K` may actually be a reference to begin with. For this purpose,
342 you can use `__result_of_value_at_key__<S, K>`.]
344 [heading Expression Semantics]
347 [[Expression] [Semantics]]
348 [[`__has_key__<K>(s)`] [A boolean Integral Constant `c` such that
349 `c::value == true` if and only if there is
350 one or more elements with the key `k` in `s`;
352 [[`__at_key__<K>(s)`] [The element associated with the key
353 `K` in the sequence `s`; see __at__.]]
360 * __filter_view__ (where adapted sequence is an __associative_sequence__ and a __forward_sequence__)
361 * __iterator_range__ (where adapted iterators are __associative_iterator__\ s)
362 * __joint_view__ (where adapted sequences are __associative_sequence__\ s and __forward_sequence__\ s)
363 * __reverse_view__ (where adapted sequence is an __associative_sequence__ and a __bidirectional_sequence__)
367 [section Unbounded Sequence]
369 [heading Description]
371 A Unbounded Sequence allows Out-of-Bounds access: it will achieve something like a __window_function__.
372 Most of the sequences do not meet this concept, but some special usecases do.
374 [important User extending sequences should handle any parameters or be SFINAE-friendly.]
376 [variablelist Notation
377 [[`s`] [An Fusion Sequence]]
378 [[`S`] [An Fusion Sequence type]]
379 [[`M`] [An __mpl__ integral constant]]
380 [[`N`] [An integral constant]]
381 [[`K`] [An arbitrary /key/ type]]
382 [[`o`] [An arbitrary object]]
383 [[`e`] [A Sequence element]]
386 [heading Valid Expressions]
389 [[Expression] [Return type] [Type Requirements] [Runtime Complexity]]
390 [[`__at_c__<N>(s)`] [Any type] [] [Depends on its traversability]]
391 [[`__at_c__<N>(s) = o`] [Any type] [] [Depends on its traversability]]
392 [[`__at__<M>(s)`] [Any type] [] [Depends on its traversability]]
393 [[`__at__<M>(s) = o`] [Any type] [] [Depends on its traversability]]
394 [[`__at_key__<K>(s)`] [Any type] [`S` should be __associative_sequence__] [Depends on its traversability]]
395 [[`__at_key__<K>(s) = o`] [Any type] [`S` should be __associative_sequence__] [Depends on its traversability]]
398 [heading Result Type Expressions]
401 [[Expression] [Compile Time Complexity]]
402 [[`__result_of_at__<S, M>::type`] [Depends on its traversability]]
403 [[`__result_of_at_c__<S, N>::type`] [Depends on its traversability]]
404 [[`__result_of_value_at__<S, M>::type`] [Depends on its traversability]]
405 [[`__result_of_value_at_c__<S, N>::type`] [Depends on its traversability]]
406 [[`__result_of_at_key__<S, K>::type`] [Depends on its traversability]]
407 [[`__result_of_value_at_key__<S, K>::type`] [Depends on its traversability]]
420 Intrinsic form the essential interface of every Fusion __sequence__. __stl__
421 counterparts of these functions are usually implemented as member
422 functions. Intrinsic functions, unlike __algorithms__, are not generic
423 across the full __sequence__ repertoire. They need to be implemented for
424 each Fusion __sequence__[footnote In practice, many of intrinsic functions
425 have default implementations that will work in majority of cases].
429 #include <boost/fusion/sequence/intrinsic.hpp>
430 #include <boost/fusion/include/intrinsic.hpp>
436 [heading Description]
438 Returns an iterator pointing to the first element in the sequence.
442 template <typename Sequence>
443 typename __result_of_begin__<Sequence>::type
444 begin(Sequence& seq);
446 template <typename Sequence>
447 typename __result_of_begin__<Sequence const>::type
448 begin(Sequence const& seq);
453 [[Parameter] [Requirement] [Description]]
454 [[`seq`] [Model of __forward_sequence__] [The sequence we wish to get an iterator from.]]
457 [heading Expression Semantics]
463 * A model of __forward_iterator__ if `seq` is a __forward_sequence__
464 else, __bidirectional_iterator__ if `seq` is a __bidirectional_sequence__
465 else, __random_access_iterator__ if `seq` is a __random_access_sequence__.
466 * A model of __associative_iterator__ if `seq` is an __associative_sequence__.
468 [*Semantics]: Returns an iterator pointing to the first element in the sequence.
472 #include <boost/fusion/sequence/intrinsic/begin.hpp>
473 #include <boost/fusion/include/begin.hpp>
477 __vector__<int, int, int> v(1, 2, 3);
478 assert(__deref__(begin(v)) == 1);
484 [heading Description]
486 Returns an iterator pointing to one element past the end of the sequence.
490 template <typename Sequence>
491 typename __result_of_end__<Sequence>::type
494 template <typename Sequence>
495 typename __result_of_end__<Sequence const>::type
496 end(Sequence const& seq);
501 [[Parameter] [Requirement] [Description]]
502 [[`seq`] [Model of __forward_sequence__] [The sequence we wish to get an iterator from.]]
505 [heading Expression Semantics]
511 * A model of __forward_iterator__ if `seq` is a __forward_sequence__
512 else, __bidirectional_iterator__ if `seq` is a __bidirectional_sequence__
513 else, __random_access_iterator__ if `seq` is a __random_access_sequence__.
514 * A model of __associative_iterator__ if `seq` is an __associative_sequence__.
516 [*Semantics]: Returns an iterator pointing to one element past the end of
521 #include <boost/fusion/sequence/intrinsic/end.hpp>
522 #include <boost/fusion/include/end.hpp>
526 __vector__<int, int, int> v(1, 2, 3);
527 assert(__deref__(__prior__(end(v))) == 3);
533 [heading Description]
535 Returns a type convertible to `bool` that evaluates to `true` if the
536 sequence is empty, else, evaluates to `false`.
540 template <typename Sequence>
541 typename __result_of_empty__<Sequence>::type
542 empty(Sequence const& seq);
547 [[Parameter] [Requirement] [Description]]
548 [[`seq`] [Model of __forward_sequence__] [The sequence we wish to investigate.]]
551 [heading Expression Semantics]
555 [*Return type]: Convertible to `bool`.
557 [*Semantics]: Evaluates to `true` if the sequence is empty, else, evaluates
562 #include <boost/fusion/sequence/intrinsic/empty.hpp>
563 #include <boost/fusion/include/empty.hpp>
567 __vector__<int, int, int> v(1, 2, 3);
568 assert(empty(v) == false);
574 [heading Description]
576 Returns the first element in the sequence.
580 template <typename Sequence>
581 typename __result_of_front__<Sequence>::type
582 front(Sequence& seq);
584 template <typename Sequence>
585 typename __result_of_front__<Sequence const>::type
586 front(Sequence const& seq);
591 [[Parameter] [Requirement] [Description]]
592 [[`seq`] [Model of __forward_sequence__] [The sequence we wish to investigate.]]
595 [heading Expression Semantics]
599 [*Return type]: Returns a reference to the first element in the sequence
600 `seq` if `seq` is mutable and `e = o`, where `e` is the first element in
601 the sequence, is a valid expression. Else, returns a type convertible to
602 the first element in the sequence.
604 [*Precondition]: `__empty__(seq) == false`
606 [*Semantics]: Returns the first element in the sequence.
610 #include <boost/fusion/sequence/intrinsic/front.hpp>
611 #include <boost/fusion/include/front.hpp>
615 __vector__<int, int, int> v(1, 2, 3);
616 assert(front(v) == 1);
622 [heading Description]
624 Returns the last element in the sequence.
628 template <typename Sequence>
629 typename __result_of_back__<Sequence>::type
632 template <typename Sequence>
633 typename __result_of_back__<Sequence const>::type
634 back(Sequence const& seq);
639 [[Parameter] [Requirement] [Description]]
640 [[`seq`] [Model of __bidirectional_sequence__] [The sequence we wish to investigate.]]
643 [heading Expression Semantics]
647 [*Return type]: Returns a reference to the last element in the sequence
648 `seq` if `seq` is mutable and `e = o`, where `e` is the last element in the
649 sequence, is a valid expression. Else, returns a type convertible to the
650 last element in the sequence.
652 [*Precondition]: `__empty__(seq) == false`
654 [*Semantics]: Returns the last element in the sequence.
658 #include <boost/fusion/sequence/intrinsic/back.hpp>
659 #include <boost/fusion/include/back.hpp>
663 __vector__<int, int, int> v(1, 2, 3);
664 assert(back(v) == 3);
670 [heading Description]
672 Returns a type convertible to `int` that evaluates the number of elements
677 template <typename Sequence>
678 typename __result_of_size__<Sequence>::type
679 size(Sequence const& seq);
684 [[Parameter] [Requirement] [Description]]
685 [[`seq`] [Model of __forward_sequence__] [The sequence we wish to investigate.]]
688 [heading Expression Semantics]
692 [*Return type]: Convertible to `int`.
694 [*Semantics]: Returns the number of elements in the sequence.
698 #include <boost/fusion/sequence/intrinsic/size.hpp>
699 #include <boost/fusion/include/size.hpp>
703 __vector__<int, int, int> v(1, 2, 3);
704 assert(size(v) == 3);
710 [heading Description]
712 Returns the M-th element from the beginning of the sequence.
716 template <typename M, typename Sequence>
717 typename __result_of_at__<Sequence, N>::type
720 template <typename M, typename Sequence>
721 typename __result_of_at__<Sequence const, N>::type
722 at(Sequence const& seq);
727 [[Parameter] [Requirement] [Description]]
728 [[`seq`] [Model of __random_access_sequence__] [The sequence we wish to investigate.]]
729 [[`M`] [An __mpl_integral_constant__] [An index from the beginning of the
733 [heading Expression Semantics]
737 [*Return type]: Returns a reference to the M-th element from the beginning
738 of the sequence `seq` if `seq` is mutable and `e = o`, where `e` is the M-th
739 element from the beginning of the sequence, is a valid expression. Else,
740 returns a type convertible to the M-th element from the beginning of the
743 [*Precondition]: `0 <= M::value < __size__(seq)` (where `seq` is not __unbounded_sequence__)
745 [*Semantics]: Equivalent to
747 __deref__(__advance__<M>(__begin__(s)))
751 #include <boost/fusion/sequence/intrinsic/at.hpp>
752 #include <boost/fusion/include/at.hpp>
756 __vector__<int, int, int> v(1, 2, 3);
757 assert(at<mpl::int_<1> >(v) == 2);
763 [heading Description]
765 Returns the N-th element from the beginning of the sequence.
769 template <int N, typename Sequence>
770 typename __result_of_at_c__<Sequence, N>::type
773 template <int N, typename Sequence>
774 typename __result_of_at_c__<Sequence const, N>::type
775 at_c(Sequence const& seq);
780 [[Parameter] [Requirement] [Description]]
781 [[`seq`] [Model of __random_access_sequence__] [The sequence we wish to investigate.]]
782 [[`N`] [An integral constant] [An index from the beginning of the
786 [heading Expression Semantics]
790 [*Return type]: Returns a reference to the N-th element from the beginning
791 of the sequence `seq` if `seq` is mutable and `e = o`, where `e` is the N-th
792 element from the beginning of the sequence, is a valid expression. Else,
793 returns a type convertible to the N-th element from the beginning of the
796 [*Precondition]: `0 <= N < __size__(seq)` (where `seq` is not __unbounded_sequence__)
798 [*Semantics]: Equivalent to
800 __deref__(__advance__<N>(__begin__(s)))
804 #include <boost/fusion/sequence/intrinsic/at_c.hpp>
805 #include <boost/fusion/include/at_c.hpp>
809 __vector__<int, int, int> v(1, 2, 3);
810 assert(at_c<1>(v) == 2);
816 [heading Description]
818 Returns a type convertible to `bool` that evaluates to `true` if the
819 sequence contains an element associated with a Key, else, evaluates to
824 template <typename Key, typename Sequence>
825 typename __result_of_has_key__<Sequence, Key>::type
826 has_key(Sequence const& seq);
831 [[Parameter] [Requirement] [Description]]
832 [[`seq`] [Model of __associative_sequence__] [The sequence we wish to investigate.]]
833 [[`Key`] [Any type] [The queried key.]]
836 [heading Expression Semantics]
840 [*Return type]: Convertible to `bool`.
842 [*Semantics]: Evaluates to `true` if the sequence contains an element
843 associated with Key, else, evaluates to `false`.
847 #include <boost/fusion/sequence/intrinsic/has_key.hpp>
848 #include <boost/fusion/include/has_key.hpp>
852 __set__<int, char, bool> s(1, 'x', true);
853 assert(has_key<char>(s) == true);
859 [heading Description]
861 Returns the element associated with a Key from the sequence.
865 template <typename Key, typename Sequence>
866 typename __result_of_at_key__<Sequence, Key>::type
867 at_key(Sequence& seq);
869 template <typename Key, typename Sequence>
870 typename __result_of_at_key__<Sequence const, Key>::type
871 at_key(Sequence const& seq);
876 [[Parameter] [Requirement] [Description]]
877 [[`seq`] [Model of __associative_sequence__] [The sequence we wish to investigate.]]
878 [[`Key`] [Any type] [The queried key.]]
881 [heading Expression Semantics]
885 [*Return type]: Returns a reference to the element associated with Key from
886 the sequence `seq` if `seq` is mutable and `e = o`, where `e` is the
887 element associated with Key, is a valid expression. Else, returns a type
888 convertible to the element associated with Key.
890 [*Precondition]: `has_key<Key>(seq) == true` (where `seq` is not __unbounded_sequence__)
892 [*Semantics]: Returns the element associated with Key.
896 #include <boost/fusion/sequence/intrinsic/at_key.hpp>
897 #include <boost/fusion/include/at_key.hpp>
901 __set__<int, char, bool> s(1, 'x', true);
902 assert(at_key<char>(s) == 'x');
908 [heading Description]
910 Performs an element by element swap of the elements in 2 sequences.
913 template<typename Seq1, typename Seq2>
914 typename __result_of_swap__<Seq1, Seq2>::type
915 swap(Seq1& seq1, Seq2& seq2);
920 [[Parameters] [Requirement] [Description]]
921 [[`seq1`, `seq2`][Models of __forward_sequence__][The sequences whose elements we wish to swap.]]
924 [heading Expression Semantics]
928 [*Return type]: `void`
930 [*Precondition]: `__size__(seq1) == __size__(seq2)`
932 [*Semantics]: Calls `swap(a1, b1)` for corresponding elements in `seq1` and `seq2`.
936 #include <boost/fusion/sequence/intrinsic/swap.hpp>
937 #include <boost/fusion/include/swap.hpp>
940 __vector__<int, std::string> v1(1, "hello"), v2(2, "world");
942 assert(v1 == __make_vector__(2, "world"));
943 assert(v2 == __make_vector__(1, "hello"));
949 [section Metafunctions]
953 [heading Description]
954 Returns the result type of __begin__.
957 template<typename Seq>
960 typedef __unspecified__ type;
964 [[Parameter] [Requirement] [Description]]
965 [[`Seq`][A model of __forward_sequence__][Argument sequence]]
968 [heading Expression Semantics]
969 result_of::begin<Seq>::type
973 * A model of __forward_iterator__ if `seq` is a __forward_sequence__
974 else, __bidirectional_iterator__ if `seq` is a __bidirectional_sequence__
975 else, __random_access_iterator__ if `seq` is a __random_access_sequence__.
976 * A model of __associative_iterator__ if `seq` is an __associative_sequence__.
978 [*Semantics]: Returns the type of an iterator to the first element of `Seq`.
982 #include <boost/fusion/sequence/intrinsic/begin.hpp>
983 #include <boost/fusion/include/begin.hpp>
986 typedef __vector__<int> vec;
987 typedef __result_of_begin__<vec>::type it;
988 BOOST_MPL_ASSERT((boost::is_same<__result_of_deref__<it>::type, int&>))
994 [heading Description]
995 Returns the result type of __end__.
998 template<typename Seq>
1001 typedef __unspecified__ type;
1005 [[Parameter] [Requirement] [Description]]
1006 [[`Seq`][A model of __forward_sequence__][Argument sequence]]
1009 [heading Expression Semantics]
1010 result_of::end<Seq>::type
1014 * A model of __forward_iterator__ if `seq` is a __forward_sequence__
1015 else, __bidirectional_iterator__ if `seq` is a __bidirectional_sequence__
1016 else, __random_access_iterator__ if `seq` is a __random_access_sequence__.
1017 * A model of __associative_iterator__ if `seq` is an __associative_sequence__.
1019 [*Semantics]: Returns the type of an iterator one past the end of `Seq`.
1023 #include <boost/fusion/sequence/intrinsic/end.hpp>
1024 #include <boost/fusion/include/end.hpp>
1027 typedef __vector__<int> vec;
1028 typedef __result_of_prior__<__result_of_end__<vec>::type>::type first;
1029 BOOST_MPL_ASSERT((__result_of_equal_to__<first, __result_of_begin__<vec>::type>))
1035 [heading Description]
1036 Returns the result type of __empty__.
1039 template<typename Seq>
1042 typedef __unspecified__ type;
1046 [[Parameter] [Requirement] [Description]]
1047 [[`Seq`][A model of __forward_sequence__][Argument sequence]]
1050 [heading Expression Semantics]
1051 result_of::empty<Seq>::type
1053 [*Return type]: An __mpl_integral_constant__
1055 [*Semantics]: Returns `mpl::true_` if `Seq` has zero elements, `mpl::false_` otherwise.
1059 #include <boost/fusion/sequence/intrinsic/empty.hpp>
1060 #include <boost/fusion/include/empty.hpp>
1063 typedef __vector__<> empty_vec;
1064 typedef __vector__<int,float,char> vec;
1066 BOOST_MPL_ASSERT((__result_of_empty__<empty_vec>));
1067 BOOST_MPL_ASSERT_NOT((__result_of_empty__<vec>));
1073 [heading Description]
1074 Returns the result type of __front__.
1077 template<typename Seq>
1080 typedef __unspecified__ type;
1084 [[Parameter] [Requirement] [Description]]
1085 [[`Seq`][A model of __forward_sequence__][Argument sequence]]
1088 [heading Expression Semantics]
1089 result_of::front<Seq>::type
1091 [*Return type]: Any type
1093 [*Semantics]: The type returned by dereferencing an iterator to the first element in `Seq`. Equivalent to `__result_of_deref__<__result_of_begin__<Seq>::type>::type`.
1097 #include <boost/fusion/sequence/intrinsic/front.hpp>
1098 #include <boost/fusion/include/front.hpp>
1101 typedef __vector__<int,char> vec;
1102 BOOST_MPL_ASSERT((boost::is_same<__result_of_front__<vec>::type, int&>));
1108 [heading Description]
1109 Returns the result type of __back__.
1112 template<typename Seq>
1115 typedef __unspecified__ type;
1119 [[Parameter] [Requirement] [Description]]
1120 [[`Seq`][A model of __forward_sequence__][Argument sequence]]
1123 [heading Expression Semantics]
1124 result_of::back<Seq>::type
1126 [*Return type]: Any type
1128 [*Semantics]: The type returned by dereferencing an iterator to the last element in the sequence. Equivalent to `__result_of_deref__<__result_of_prior__<__result_of_end__<Seq>::type>::type>::type`.
1132 #include <boost/fusion/sequence/intrinsic/back.hpp>
1133 #include <boost/fusion/include/back.hpp>
1136 typedef __vector__<int,char> vec;
1137 BOOST_MPL_ASSERT((boost::is_same<__result_of_back__<vec>::type, char&>));
1143 [heading Description]
1144 Returns the result type of __size__.
1147 template<typename Seq>
1150 typedef __unspecified__ type;
1154 [[Parameter] [Requirement] [Description]]
1155 [[`Seq`][A model of __forward_sequence__][Argument sequence]]
1158 [heading Expression Semantics]
1159 result_of::size<Seq>::type
1161 [*Return type]: An __mpl_integral_constant__.
1163 [*Semantics]: Returns the number of elements in `Seq`.
1167 #include <boost/fusion/sequence/intrinsic/size.hpp>
1168 #include <boost/fusion/include/size.hpp>
1171 typedef __vector__<int,float,char> vec;
1172 typedef __result_of_size__<vec>::type size_mpl_integral_constant;
1173 BOOST_MPL_ASSERT_RELATION(size_mpl_integral_constant::value, ==, 3);
1179 [heading Description]
1181 Returns the result type of __at__[footnote __result_of_at__ reflects the
1182 actual return type of the function __at__. __sequence__(s) typically return
1183 references to its elements via the __at__ function. If you want to get
1184 the actual element type, use __result_of_value_at__].
1192 typedef __unspecified__ type;
1196 [[Parameter] [Requirement] [Description]]
1197 [[`Seq`][A model of __random_access_sequence__][Argument sequence]]
1198 [[`M`][An __mpl_integral_constant__][Index of element]]
1201 [heading Expression Semantics]
1202 result_of::at<Seq, M>::type
1204 [*Return type]: Any type.
1206 [*Precondition]: `0 <= M::value < __result_of_size__<Seq>::value` (where `Seq` is not __unbounded_sequence__)
1208 [*Semantics]: Returns the result type of using __at__ to access the `M`th element of `Seq`.
1212 #include <boost/fusion/sequence/intrinsic/at.hpp>
1213 #include <boost/fusion/include/at.hpp>
1216 typedef __vector__<int,float,char> vec;
1217 BOOST_MPL_ASSERT((boost::is_same<__result_of_at__<vec, boost::mpl::int_<1> >::type, float&>));
1223 [heading Description]
1225 Returns the result type of __at_c__[footnote __result_of_at_c__ reflects
1226 the actual return type of the function __at_c__. __sequence__(s) typically
1227 return references to its elements via the __at_c__ function. If you want to
1228 get the actual element type, use __result_of_value_at_c__].
1236 typedef __unspecified__ type;
1240 [[Parameter] [Requirement] [Description]]
1241 [[`Seq`][A model of __random_access_sequence__][Argument sequence]]
1242 [[`N`][Positive integer index][Index of element]]
1245 [heading Expression Semantics]
1246 result_of::at_c<Seq, N>::type
1248 [*Return type]: Any type
1250 [*Precondition]: `0 <= N < __result_of_size__<Seq>::value` (where `Seq` is not __unbounded_sequence__)
1252 [*Semantics]: Returns the result type of using __at_c__ to access the `N`th element of `Seq`.
1256 #include <boost/fusion/sequence/intrinsic/at.hpp>
1257 #include <boost/fusion/include/at.hpp>
1260 typedef __vector__<int,float,char> vec;
1261 BOOST_MPL_ASSERT((boost::is_same<__result_of_at_c__<vec, 1>::type, float&>));
1267 [heading Description]
1269 Returns the actual type at a given index from the __sequence__.
1277 typedef __unspecified__ type;
1281 [[Parameter] [Requirement] [Description]]
1282 [[`Seq`][A model of __random_access_sequence__][Argument sequence]]
1283 [[`M`][An __mpl_integral_constant__][Index of element]]
1286 [heading Expression Semantics]
1287 result_of::value_at<Seq, M>::type
1289 [*Return type]: Any type.
1291 [*Semantics]: Returns the actual type at the `M`th element of `Seq`.
1295 #include <boost/fusion/sequence/intrinsic/value_at.hpp>
1296 #include <boost/fusion/include/value_at.hpp>
1299 typedef __vector__<int,float,char> vec;
1300 BOOST_MPL_ASSERT((boost::is_same<__result_of_value_at__<vec, boost::mpl::int_<1> >::type, float>));
1304 [section value_at_c]
1306 [heading Description]
1308 Returns the actual type at a given index from the __sequence__.
1316 typedef __unspecified__ type;
1320 [[Parameter] [Requirement] [Description]]
1321 [[`Seq`][A model of __random_access_sequence__][Argument sequence]]
1322 [[`N`][Positive integer index][Index of element]]
1325 [heading Expression Semantics]
1326 result_of::value_at_c<Seq, N>::type
1328 [*Return type]: Any type
1330 [*Semantics]: Returns the actual type at the `N`th element of `Seq`.
1334 #include <boost/fusion/sequence/intrinsic/value_at.hpp>
1335 #include <boost/fusion/include/value_at.hpp>
1338 typedef __vector__<int,float,char> vec;
1339 BOOST_MPL_ASSERT((boost::is_same<__result_of_value_at_c__<vec, 1>::type, float>));
1345 [heading Description]
1346 Returns the result type of __has_key__.
1354 typedef __unspecified__ type;
1358 [[Parameter] [Requirement] [Description]]
1359 [[`Seq`][A model of __associative_sequence__][Argument sequence]]
1360 [[`Key`][Any type][Key type]]
1363 [heading Expression Semantics]
1364 result_of::has_key<Seq, Key>::type
1366 [*Return type]: An __mpl_integral_constant__.
1368 [*Semantics]: Returns `mpl::true_` if `Seq` contains an element with key type `Key`, returns `mpl::false_` otherwise.
1372 #include <boost/fusion/sequence/intrinsic/has_key.hpp>
1373 #include <boost/fusion/include/has_key.hpp>
1376 typedef __map__<__pair__<int, char>, __pair__<char, char>, __pair__<double, char> > mymap;
1377 BOOST_MPL_ASSERT((__result_of_has_key__<mymap, int>));
1378 BOOST_MPL_ASSERT_NOT((__result_of_has_key__<mymap, void*>));
1384 [heading Description]
1386 Returns the result type of __at_key__[footnote __result_of_at_key__
1387 reflects the actual return type of the function __at_key__. __sequence__(s)
1388 typically return references to its elements via the __at_key__ function. If
1389 you want to get the actual element type, use __result_of_value_at_key__].
1397 typedef __unspecified__ type;
1401 [[Parameter] [Requirement] [Description]]
1402 [[`Seq`][A model of __associative_sequence__][Argument sequence]]
1403 [[`Key`][Any type][Key type]]
1406 [heading Expression Semantics]
1407 result_of::at_key<Seq, Key>::type
1409 [*Return type]: Any type.
1411 [*Precondition]: `has_key<Seq, Key>::type::value == true` (where `Seq` is not __unbounded_sequence__)
1413 [*Semantics]: Returns the result of using __at_key__ to access the element with key type `Key` in `Seq`.
1417 #include <boost/fusion/sequence/intrinsic/at_key.hpp>
1418 #include <boost/fusion/include/at_key.hpp>
1421 typedef __map__<__pair__<int, char>, __pair__<char, char>, __pair__<double, char> > mymap;
1422 BOOST_MPL_ASSERT((boost::is_same<__result_of_at_key__<mymap, int>::type, char&>));
1426 [section value_at_key]
1428 [heading Description]
1429 Returns the actual element type associated with a Key from the __sequence__.
1437 typedef __unspecified__ type;
1441 [[Parameter] [Requirement] [Description]]
1442 [[`Seq`][A model of __associative_sequence__][Argument sequence]]
1443 [[`Key`][Any type][Key type]]
1446 [heading Expression Semantics]
1447 result_of::value_at_key<Seq, Key>::type
1449 [*Return type]: Any type.
1451 [*Precondition]: `has_key<Seq, Key>::type::value == true` (where `Seq` is not __unbounded_sequence__)
1453 [*Semantics]: Returns the actual element type associated with key type
1458 #include <boost/fusion/sequence/intrinsic/value_at_key.hpp>
1459 #include <boost/fusion/include/value_at_key.hpp>
1462 typedef __map__<__pair__<int, char>, __pair__<char, char>, __pair__<double, char> > mymap;
1463 BOOST_MPL_ASSERT((boost::is_same<__result_of_value_at_key__<mymap, int>::type, char>));
1469 [heading Description]
1470 Returns the return type of swap.
1473 template<typename Seq1, typename Seq2>
1480 [[Parameters] [Requirement] [Description]]
1481 [[`Seq1`, `Seq2`][Models of __forward_sequence__][The sequences being swapped]]
1484 [heading Expression Semantics]
1485 result_of::swap<Seq1, Seq2>::type
1487 [*Return type]: `void` iff both of `Seq1` and `Seq2` are sequence.
1490 [*Semantics]: Returns the return type of __swap__ for 2 sequences of types `Seq1` and `Seq2`.
1494 #include <boost/fusion/sequence/intrinsic/swap.hpp>
1495 #include <boost/fusion/include/swap.hpp>
1505 These operators, like the __algorithms__, work generically on all Fusion
1506 sequences. All conforming Fusion sequences automatically get these
1511 The I/O operators: `<<` and `>>` work generically on all Fusion
1512 sequences. The I/O operators are overloaded in namespace `boost::fusion`
1513 [footnote __sequence__(s) and __views__ residing in different namespaces
1514 will have to either provide their own I/O operators (possibly forwarding
1515 to fusion's I/O operators) or hoist fusion's I/O operators (using
1516 declaration), in their own namespaces for proper argument dependent
1519 The `operator<<` has been overloaded for generic output streams such
1520 that __sequence__(s) are output by recursively calling `operator<<` for
1521 each element. Analogously, the global `operator>>` has been overloaded
1522 to extract __sequence__(s) from generic input streams by recursively
1523 calling `operator>>` for each element.
1525 The default delimiter between the elements is space, and the __sequence__
1526 is enclosed in parenthesis. For Example:
1528 __vector__<float, int, std::string> a(1.0f, 2, std::string("Howdy folks!");
1531 outputs the __vector__ as: (1.0 2 Howdy folks!)
1533 The library defines three manipulators for changing the default behavior:
1535 [variablelist Manipulators
1536 [[`tuple_open(arg)`] [Defines the character that is output before the first element.]]
1537 [[`tuple_close(arg)`] [Defines the character that is output after the last element.]]
1538 [[`tuple_delimiter(arg)`] [Defines the delimiter character between elements.]]
1541 The argument to `tuple_open`, `tuple_close` and `tuple_delimiter` may be a
1542 `char`, `wchar_t`, a C-string, or a wide C-string.
1546 std::cout << tuple_open('[') << tuple_close(']') << tuple_delimiter(", ") << a;
1548 outputs the same __vector__, `a` as: [1.0, 2, Howdy folks!]
1550 The same manipulators work with `operator>>` and `istream` as well. Suppose
1551 the `std::cin` stream contains the following data:
1557 __vector__<int, int, int> i;
1558 __vector__<int, int> j;
1561 std::cin >> tuple_open('[') >> tuple_close(']') >> tuple_delimiter(':');
1564 reads the data into the __vector__(s) `i` and `j`.
1566 Note that extracting __sequence__(s) with `std::string` or C-style string
1567 elements does not generally work, since the streamed __sequence__
1568 representation may not be unambiguously parseable.
1572 #include <boost/fusion/sequence/io.hpp>
1573 #include <boost/fusion/include/io.hpp>
1577 [heading Description]
1579 Read a __sequence__ from an input stream.
1583 template <typename IStream, typename Sequence>
1585 operator>>(IStream& is, Sequence& seq);
1587 [heading Parameters]
1590 [[Parameter] [Requirement] [Description]]
1591 [[is] [An input stream.] [Stream to extract information from.]]
1592 [[seq] [A __sequence__.] [The sequence to read.]]
1595 [heading Expression Semantics]
1599 [*Return type]: IStream&
1601 [*Semantics]: For each element, `e`, in sequence, `seq`, call `is >> e`.
1605 #include <boost/fusion/sequence/io/in.hpp>
1606 #include <boost/fusion/include/in.hpp>
1610 __vector__<int, std::string, char> v;
1617 [heading Description]
1619 Write a __sequence__ to an output stream.
1623 template <typename OStream, typename Sequence>
1625 operator<<(OStream& os, Sequence& seq);
1627 [heading Parameters]
1630 [[Parameter] [Requirement] [Description]]
1631 [[os] [An output stream.] [Stream to write information to.]]
1632 [[seq] [A __sequence__.] [The sequence to write.]]
1635 [heading Expression Semantics]
1639 [*Return type]: OStream&
1641 [*Semantics]: For each element, `e`, in sequence, `seq`, call `os << e`.
1645 #include <boost/fusion/sequence/io/out.hpp>
1646 #include <boost/fusion/include/out.hpp>
1650 std::cout << __make_vector__(123, "Hello", 'x') << std::endl;
1656 [section Comparison]
1658 The Comparison operators: `==`, `!=`, `<`, `<=`, `>=` and `>=` work
1659 generically on all Fusion sequences. Comparison operators are "short-
1660 circuited": elementary comparisons start from the first elements and are
1661 performed only until the result is clear.
1665 #include <boost/fusion/sequence/comparison.hpp>
1666 #include <boost/fusion/include/comparison.hpp>
1670 [heading Description]
1672 Compare two sequences for equality.
1676 template <typename Seq1, typename Seq2>
1678 operator==(Seq1 const& a, Seq2 const& b);
1680 [heading Parameters]
1683 [[Parameter] [Requirement] [Description]]
1684 [[`a, b`] [Instances of __sequence__] [__sequence__(s) to compare]]
1687 [heading Expression Semantics]
1691 [*Return type]: `bool`
1695 For each element, `e1`, in sequence `a`, and for each element, `e2`, in
1696 sequence `b`, `a == b` is a valid expression returning a type that is
1697 convertible to bool.
1699 An attempt to compare two Sequences of different lengths results in a
1704 For each element, `e1`, in sequence `a`, and for each element, `e2`, in
1705 sequence `b`, `e1 == e2` returns true. For any 2 zero length __sequence__(s),
1706 e and f, e == f returns true.
1710 #include <boost/fusion/sequence/comparison/equal_to.hpp>
1711 #include <boost/fusion/include/equal_to.hpp>
1715 __vector__<int, char> v1(5, 'a');
1716 __vector__<int, char> v2(5, 'a');
1723 Compare two sequences for inequality.
1727 template <typename Seq1, typename Seq2>
1729 operator!=(Seq1 const& a, Seq2 const& b);
1731 [heading Parameters]
1734 [[Parameter] [Requirement] [Description]]
1735 [[`a, b`] [Instances of __sequence__] [__sequence__(s) to compare]]
1738 [heading Expression Semantics]
1742 [*Return type]: `bool`
1746 For each element, `e1`, in sequence `a`, and for each element, `e2`, in
1747 sequence `b`, `a == b` is a valid expression returning a type that is
1748 convertible to bool.
1750 An attempt to compare two Sequences of different lengths results in a
1759 #include <boost/fusion/sequence/comparison/not_equal_to.hpp>
1760 #include <boost/fusion/include/not_equal_to.hpp>
1764 __vector__<int, char> v3(5, 'b');
1765 __vector__<int, char> t4(2, 'a');
1768 assert(!(v1 != v2));
1774 Lexicographically compare two sequences.
1778 template <typename Seq1, typename Seq2>
1780 operator<(Seq1 const& a, Seq2 const& b);
1782 [heading Parameters]
1785 [[Parameter] [Requirement] [Description]]
1786 [[`a, b`] [Instances of __sequence__] [__sequence__(s) to compare]]
1789 [heading Expression Semantics]
1793 [*Return type]: `bool`
1797 For each element, `e1`, in sequence `a`, and for each element, `e2`, in
1798 sequence `b`, `a < b` is a valid expression returning a type that is
1799 convertible to bool.
1801 An attempt to compare two Sequences of different lengths results in a
1804 [*Semantics]: Returns the lexicographical comparison of between `a` and `b`.
1808 #include <boost/fusion/sequence/comparison/less.hpp>
1809 #include <boost/fusion/include/less.hpp>
1813 __vector__<int, float> v1(4, 3.3f);
1814 __vector__<short, float> v2(5, 3.3f);
1815 __vector__<long, double> v3(5, 4.4);
1821 [section less than equal]
1823 Lexicographically compare two sequences.
1827 template <typename Seq1, typename Seq2>
1829 operator<=(Seq1 const& a, Seq2 const& b);
1831 [heading Parameters]
1834 [[Parameter] [Requirement] [Description]]
1835 [[`a, b`] [Instances of __sequence__] [__sequence__(s) to compare]]
1838 [heading Expression Semantics]
1842 [*Return type]: `bool`
1846 For each element, `e1`, in sequence `a`, and for each element, `e2`, in
1847 sequence `b`, `a < b` is a valid expression returning a type that is
1848 convertible to bool.
1850 An attempt to compare two Sequences of different lengths results in a
1853 [*Semantics]: Returns !(b < a).
1857 #include <boost/fusion/sequence/comparison/less_equal.hpp>
1858 #include <boost/fusion/include/less_equal.hpp>
1862 __vector__<int, float> v1(4, 3.3f);
1863 __vector__<short, float> v2(5, 3.3f);
1864 __vector__<long, double> v3(5, 4.4);
1870 [section greater than]
1872 Lexicographically compare two sequences.
1876 template <typename Seq1, typename Seq2>
1878 operator>(Seq1 const& a, Seq2 const& b);
1880 [heading Parameters]
1883 [[Parameter] [Requirement] [Description]]
1884 [[`a, b`] [Instances of __sequence__] [__sequence__(s) to compare]]
1887 [heading Expression Semantics]
1891 [*Return type]: `bool`
1895 For each element, `e1`, in sequence `a`, and for each element, `e2`, in
1896 sequence `b`, `a < b` is a valid expression returning a type that is
1897 convertible to bool.
1899 An attempt to compare two Sequences of different lengths results in a
1902 [*Semantics]: Returns b < a.
1906 #include <boost/fusion/sequence/comparison/less_equal.hpp>
1907 #include <boost/fusion/include/less_equal.hpp>
1911 __vector__<int, float> v1(4, 3.3f);
1912 __vector__<short, float> v2(5, 3.3f);
1913 __vector__<long, double> v3(5, 4.4);
1919 [section greater than equal]
1921 Lexicographically compare two sequences.
1925 template <typename Seq1, typename Seq2>
1927 operator>=(Seq1 const& a, Seq2 const& b);
1929 [heading Parameters]
1932 [[Parameter] [Requirement] [Description]]
1933 [[`a, b`] [Instances of __sequence__] [__sequence__(s) to compare]]
1936 [heading Expression Semantics]
1940 [*Return type]: `bool`
1944 For each element, `e1`, in sequence `a`, and for each element, `e2`, in
1945 sequence `b`, `a < b` is a valid expression returning a type that is
1946 convertible to bool.
1948 An attempt to compare two Sequences of different lengths results in a
1951 [*Semantics]: Returns !(a < b).
1955 #include <boost/fusion/sequence/comparison/greater_equal.hpp>
1956 #include <boost/fusion/include/greater_equal.hpp>
1960 __vector__<int, float> v1(4, 3.3f);
1961 __vector__<short, float> v2(5, 3.3f);
1962 __vector__<long, double> v3(5, 4.4);
1972 Automatically create a `boost::hash` conforming `hash_value` function.
1976 template <typename Seq>
1978 hash_value(Seq const& seq);
1980 [heading Parameters]
1983 [[Parameter] [Requirement] [Description]]
1984 [[`seq`] [Instance of __sequence__] [__sequence__ to compute hash value of]]
1987 [*Return type]: `std::size_t`
1991 For each element `e` in sequence `seq`, `hash_value(seq)` is a valid expression
1992 returning a type that is convertible to `std::size_t`.
1994 [*Semantics]: Returns a combined hash value for all elements of `seq`.
1998 #include <boost/fusion/sequence/hash.hpp>
1999 #include <boost/fusion/include/hash.hpp>
2003 #include <boost/fusion/include/equal_to.hpp>
2004 #include <boost/fusion/include/hash.hpp>
2005 #include <boost/fusion/include/vector.hpp>
2006 #include <boost/unordered_map.hpp>
2010 typedef boost::fusion::vector<int, std::string, char> Vec;
2011 const Vec v = {42, "Hello World", 't'};
2012 // Compute a hash value directly.
2013 std::cout << "hash_value(v) = " << boost::fusion::hash_value(v) << '\n';
2014 // Or use it to create an unordered_map.
2015 boost::unordered_map<Vec, bool> map;
2017 assert(map.size() == 1 && map.count(v) == 1);
2022 #include <boost/fusion/include/define_struct.hpp>
2023 #include <boost/fusion/include/equal_to.hpp>
2024 #include <boost/fusion/include/hash.hpp>
2025 #include <boost/unordered_set.hpp>
2027 // We would like to define a struct that we can form unordered_sets of.
2028 BOOST_FUSION_DEFINE_STRUCT(
2036 // Make operator== and hash_value ADL accessible.
2037 using boost::fusion::operator==;
2038 using boost::fusion::hash_value;
2039 typedef boost::unordered_set<demo::Key> Set;
2046 assert(set.count(key) == 0);