Merge pull request #85 from Flast/feature/no_bounds_sequence

Feature/no bounds sequence
This commit is contained in:
Joel de Guzman
2015-06-25 23:09:18 +08:00
10 changed files with 161 additions and 13 deletions

View File

@ -79,6 +79,7 @@
[def __bidirectional_iterator__ [link fusion.iterator.concepts.bidirectional_iterator Bidirectional Iterator]] [def __bidirectional_iterator__ [link fusion.iterator.concepts.bidirectional_iterator Bidirectional Iterator]]
[def __random_access_iterator__ [link fusion.iterator.concepts.random_access_iterator Random Access Iterator]] [def __random_access_iterator__ [link fusion.iterator.concepts.random_access_iterator Random Access Iterator]]
[def __associative_iterator__ [link fusion.iterator.concepts.associative_iterator Associative Iterator]] [def __associative_iterator__ [link fusion.iterator.concepts.associative_iterator Associative Iterator]]
[def __unbounded_iterator__ [link fusion.iterator.concepts.unbounded_iterator Unbounded Iterator]]
[def __next__ [link fusion.iterator.functions.next `next`]] [def __next__ [link fusion.iterator.functions.next `next`]]
[def __prior__ [link fusion.iterator.functions.prior `prior`]] [def __prior__ [link fusion.iterator.functions.prior `prior`]]
@ -108,6 +109,7 @@
[def __bidirectional_sequence__ [link fusion.sequence.concepts.bidirectional_sequence Bidirectional Sequence]] [def __bidirectional_sequence__ [link fusion.sequence.concepts.bidirectional_sequence Bidirectional Sequence]]
[def __random_access_sequence__ [link fusion.sequence.concepts.random_access_sequence Random Access Sequence]] [def __random_access_sequence__ [link fusion.sequence.concepts.random_access_sequence Random Access Sequence]]
[def __associative_sequence__ [link fusion.sequence.concepts.associative_sequence Associative Sequence]] [def __associative_sequence__ [link fusion.sequence.concepts.associative_sequence Associative Sequence]]
[def __unbounded_sequence__ [link fusion.sequence.concepts.unbounded_sequence Unbounded Sequence]]
[def __containers__ [link fusion.container Container]] [def __containers__ [link fusion.container Container]]
[def __vector__ [link fusion.container.vector `vector`]] [def __vector__ [link fusion.container.vector `vector`]]
@ -337,6 +339,8 @@
[def __adt_attribute_proxy__ [link fusion.notes.adt_attribute_proxy `adt_attribute_proxy`]] [def __adt_attribute_proxy__ [link fusion.notes.adt_attribute_proxy `adt_attribute_proxy`]]
[def __window_function__ [@http://en.wikipedia.org/wiki/Window_function Window Function]]
[include preface.qbk] [include preface.qbk]
[include introduction.qbk] [include introduction.qbk]
[include quick_start.qbk] [include quick_start.qbk]

View File

@ -69,6 +69,8 @@
Access Iterator</a></span></dt> Access Iterator</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/concepts/associative_iterator.html">Associative <dt><span class="section"><a href="fusion/iterator/concepts/associative_iterator.html">Associative
Iterator</a></span></dt> Iterator</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/concepts/unbounded_iterator.html">Unbounded
Iterator</a></span></dt>
</dl></dd> </dl></dd>
<dt><span class="section"><a href="fusion/iterator/functions.html">Functions</a></span></dt> <dt><span class="section"><a href="fusion/iterator/functions.html">Functions</a></span></dt>
<dd><dl> <dd><dl>
@ -116,6 +118,8 @@
Access Sequence</a></span></dt> Access Sequence</a></span></dt>
<dt><span class="section"><a href="fusion/sequence/concepts/associative_sequence.html">Associative <dt><span class="section"><a href="fusion/sequence/concepts/associative_sequence.html">Associative
Sequence</a></span></dt> Sequence</a></span></dt>
<dt><span class="section"><a href="fusion/sequence/concepts/unbounded_sequence.html">Unbounded
Sequence</a></span></dt>
</dl></dd> </dl></dd>
<dt><span class="section"><a href="fusion/sequence/intrinsic.html">Intrinsic</a></span></dt> <dt><span class="section"><a href="fusion/sequence/intrinsic.html">Intrinsic</a></span></dt>
<dd><dl> <dd><dl>
@ -274,7 +278,7 @@
</div> </div>
</div> </div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: May 10, 2013 at 05:54:18 GMT</small></p></td> <td align="left"><p><small>Last revised: June 25, 2015 at 13:41:27 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td> <td align="right"><div class="copyright-footer"></div></td>
</tr></table> </tr></table>
<hr> <hr>

View File

@ -257,6 +257,12 @@ expressions must be valid:
[endsect] [endsect]
[section Unbounded Iterator]
[warning In this release, __unbounded_iterator__ concept has no effect. It's reserved for future release.]
[endsect]
[endsect] [endsect]
[section Functions] [section Functions]

View File

@ -39,6 +39,11 @@ These concepts pertain to sequence traversal.
The __associative_sequence__ concept is orthogonal to traversal. An Associative The __associative_sequence__ concept is orthogonal to traversal. An Associative
Sequence allows efficient retrieval of elements based on keys. Sequence allows efficient retrieval of elements based on keys.
[heading Boundary]
The __unbounded_sequence__ concept is also orthogonal to traversal and associativity.
A Unbounded Sequence allows out-of-bounds access.
[section Forward Sequence] [section Forward Sequence]
[heading Description] [heading Description]
@ -359,6 +364,55 @@ you can use `__result_of_value_at_key__<S, K>`.]
[endsect] [endsect]
[section Unbounded Sequence]
[heading Description]
A Unbounded Sequence allows Out-of-Bounds access: it will achieve something like a __window_function__.
Most of the sequences do not meet this concept, but some special usecases do.
[important User extending sequences should handle any parameters or be SFINAE-friendly.]
[variablelist Notation
[[`s`] [An Fusion Sequence]]
[[`S`] [An Fusion Sequence type]]
[[`M`] [An __mpl__ integral constant]]
[[`N`] [An integral constant]]
[[`K`] [An arbitrary /key/ type]]
[[`o`] [An arbitrary object]]
[[`e`] [A Sequence element]]
]
[heading Valid Expressions]
[table
[[Expression] [Return type] [Type Requirements] [Runtime Complexity]]
[[`__at_c__<N>(s)`] [Any type] [] [Depends on its traversability]]
[[`__at_c__<N>(s) = o`] [Any type] [] [Depends on its traversability]]
[[`__at__<M>(s)`] [Any type] [] [Depends on its traversability]]
[[`__at__<M>(s) = o`] [Any type] [] [Depends on its traversability]]
[[`__at_key__<K>(s)`] [Any type] [`S` should be __associative_sequence__] [Depends on its traversability]]
[[`__at_key__<K>(s) = o`] [Any type] [`S` should be __associative_sequence__] [Depends on its traversability]]
]
[heading Result Type Expressions]
[table
[[Expression] [Compile Time Complexity]]
[[`__result_of_at__<S, M>::type`] [Depends on its traversability]]
[[`__result_of_at_c__<S, N>::type`] [Depends on its traversability]]
[[`__result_of_value_at__<S, M>::type`] [Depends on its traversability]]
[[`__result_of_value_at_c__<S, N>::type`] [Depends on its traversability]]
[[`__result_of_at_key__<S, K>::type`] [Depends on its traversability]]
[[`__result_of_value_at_key__<S, K>::type`] [Depends on its traversability]]
]
[heading Models]
* none.
[endsect]
[endsect] [endsect]
[section Intrinsic] [section Intrinsic]
@ -686,7 +740,7 @@ element from the beginning of the sequence, is a valid expression. Else,
returns a type convertible to the M-th element from the beginning of the returns a type convertible to the M-th element from the beginning of the
sequence. sequence.
[*Precondition]: `0 <= M::value < __size__(s)` [*Precondition]: `0 <= M::value < __size__(seq)` (where `seq` is not __unbounded_sequence__)
[*Semantics]: Equivalent to [*Semantics]: Equivalent to
@ -739,7 +793,7 @@ element from the beginning of the sequence, is a valid expression. Else,
returns a type convertible to the N-th element from the beginning of the returns a type convertible to the N-th element from the beginning of the
sequence. sequence.
[*Precondition]: `0 <= N < __size__(s)` [*Precondition]: `0 <= N < __size__(seq)` (where `seq` is not __unbounded_sequence__)
[*Semantics]: Equivalent to [*Semantics]: Equivalent to
@ -833,7 +887,7 @@ the sequence `seq` if `seq` is mutable and `e = o`, where `e` is the
element associated with Key, is a valid expression. Else, returns a type element associated with Key, is a valid expression. Else, returns a type
convertible to the element associated with Key. convertible to the element associated with Key.
[*Precondition]: `has_key<Key>(seq) == true` [*Precondition]: `has_key<Key>(seq) == true` (where `seq` is not __unbounded_sequence__)
[*Semantics]: Returns the element associated with Key. [*Semantics]: Returns the element associated with Key.
@ -1149,6 +1203,8 @@ the actual element type, use __result_of_value_at__].
[*Return type]: Any type. [*Return type]: Any type.
[*Precondition]: `0 <= M::value < __result_of_size__<Seq>::value` (where `Seq` is not __unbounded_sequence__)
[*Semantics]: Returns the result type of using __at__ to access the `M`th element of `Seq`. [*Semantics]: Returns the result type of using __at__ to access the `M`th element of `Seq`.
[heading Header] [heading Header]
@ -1191,6 +1247,8 @@ get the actual element type, use __result_of_value_at_c__].
[*Return type]: Any type [*Return type]: Any type
[*Precondition]: `0 <= N < __result_of_size__<Seq>::value` (where `Seq` is not __unbounded_sequence__)
[*Semantics]: Returns the result type of using __at_c__ to access the `N`th element of `Seq`. [*Semantics]: Returns the result type of using __at_c__ to access the `N`th element of `Seq`.
[heading Header] [heading Header]
@ -1350,6 +1408,8 @@ you want to get the actual element type, use __result_of_value_at_key__].
[*Return type]: Any type. [*Return type]: Any type.
[*Precondition]: `has_key<Seq, Key>::type::value == true` (where `Seq` is not __unbounded_sequence__)
[*Semantics]: Returns the result of using __at_key__ to access the element with key type `Key` in `Seq`. [*Semantics]: Returns the result of using __at_key__ to access the element with key type `Key` in `Seq`.
[heading Header] [heading Header]
@ -1388,6 +1448,8 @@ Returns the actual element type associated with a Key from the __sequence__.
[*Return type]: Any type. [*Return type]: Any type.
[*Precondition]: `has_key<Seq, Key>::type::value == true` (where `Seq` is not __unbounded_sequence__)
[*Semantics]: Returns the actual element type associated with key type [*Semantics]: Returns the actual element type associated with key type
`Key` in `Seq`. `Key` in `Seq`.

View File

@ -227,6 +227,8 @@ And optionally from:
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
struct associative_tag {}; struct associative_tag {};
struct unbounded_tag {};
}} }}
[*Semantics]: Establishes the conceptual classification of a particular [*Semantics]: Establishes the conceptual classification of a particular

View File

@ -10,12 +10,13 @@
#include <boost/fusion/support/config.hpp> #include <boost/fusion/support/config.hpp>
#include <boost/mpl/int.hpp> #include <boost/mpl/int.hpp>
#include <boost/mpl/if.hpp> #include <boost/mpl/if.hpp>
#include <boost/mpl/or.hpp>
#include <boost/mpl/less.hpp> #include <boost/mpl/less.hpp>
#include <boost/mpl/empty_base.hpp> #include <boost/mpl/empty_base.hpp>
#include <boost/type_traits/is_const.hpp> #include <boost/type_traits/is_const.hpp>
#include <boost/fusion/sequence/intrinsic_fwd.hpp> #include <boost/fusion/sequence/intrinsic_fwd.hpp>
#include <boost/fusion/support/tag_of.hpp> #include <boost/fusion/support/tag_of.hpp>
#include <boost/fusion/support/detail/access.hpp> #include <boost/fusion/support/category_of.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
@ -64,7 +65,10 @@ namespace boost { namespace fusion
template <typename Sequence, typename N, typename Tag> template <typename Sequence, typename N, typename Tag>
struct at_impl struct at_impl
: mpl::if_< : mpl::if_<
mpl::less<N, typename extension::size_impl<Tag>::template apply<Sequence>::type> mpl::or_<
mpl::less<N, typename extension::size_impl<Tag>::template apply<Sequence>::type>
, traits::is_unbounded<Sequence>
>
, typename extension::at_impl<Tag>::template apply<Sequence, N> , typename extension::at_impl<Tag>::template apply<Sequence, N>
, mpl::empty_base , mpl::empty_base
>::type >::type

View File

@ -11,10 +11,15 @@
#include <boost/fusion/support/config.hpp> #include <boost/fusion/support/config.hpp>
#include <boost/type_traits/is_const.hpp> #include <boost/type_traits/is_const.hpp>
#include <boost/fusion/sequence/intrinsic_fwd.hpp> #include <boost/fusion/sequence/intrinsic_fwd.hpp>
#include <boost/fusion/sequence/intrinsic/has_key.hpp>
#include <boost/fusion/algorithm/query/find.hpp> #include <boost/fusion/algorithm/query/find.hpp>
#include <boost/fusion/iterator/deref_data.hpp> #include <boost/fusion/iterator/deref_data.hpp>
#include <boost/fusion/support/tag_of.hpp> #include <boost/fusion/support/tag_of.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/support/detail/access.hpp> #include <boost/fusion/support/detail/access.hpp>
#include <boost/mpl/empty_base.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/or.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
@ -64,12 +69,26 @@ namespace boost { namespace fusion
struct at_key_impl<std_pair_tag>; struct at_key_impl<std_pair_tag>;
} }
namespace detail
{
template <typename Sequence, typename Key, typename Tag>
struct at_key_impl
: mpl::if_<
mpl::or_<
typename extension::has_key_impl<Tag>::template apply<Sequence, Key>
, traits::is_unbounded<Sequence>
>
, typename extension::at_key_impl<Tag>::template apply<Sequence, Key>
, mpl::empty_base
>::type
{};
}
namespace result_of namespace result_of
{ {
template <typename Sequence, typename Key> template <typename Sequence, typename Key>
struct at_key struct at_key
: extension::at_key_impl<typename detail::tag_of<Sequence>::type>:: : detail::at_key_impl<Sequence, Key, typename detail::tag_of<Sequence>::type>
template apply<Sequence, Key>
{}; {};
} }

View File

@ -9,8 +9,13 @@
#include <boost/fusion/support/config.hpp> #include <boost/fusion/support/config.hpp>
#include <boost/mpl/int.hpp> #include <boost/mpl/int.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/or.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/empty_base.hpp>
#include <boost/fusion/sequence/intrinsic_fwd.hpp> #include <boost/fusion/sequence/intrinsic_fwd.hpp>
#include <boost/fusion/support/tag_of.hpp> #include <boost/fusion/support/tag_of.hpp>
#include <boost/fusion/support/category_of.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
@ -50,12 +55,26 @@ namespace boost { namespace fusion
struct value_at_impl<std_pair_tag>; struct value_at_impl<std_pair_tag>;
} }
namespace detail
{
template <typename Sequence, typename N, typename Tag>
struct value_at_impl
: mpl::if_<
mpl::or_<
mpl::less<N, typename extension::size_impl<Tag>::template apply<Sequence>::type>
, traits::is_unbounded<Sequence>
>
, typename extension::value_at_impl<Tag>::template apply<Sequence, N>
, mpl::empty_base
>::type
{};
}
namespace result_of namespace result_of
{ {
template <typename Sequence, typename N> template <typename Sequence, typename N>
struct value_at struct value_at
: extension::value_at_impl<typename detail::tag_of<Sequence>::type>:: : detail::value_at_impl<Sequence, N, typename detail::tag_of<Sequence>::type>
template apply<Sequence, N>
{}; {};
template <typename Sequence, int N> template <typename Sequence, int N>

View File

@ -10,10 +10,15 @@
#include <boost/fusion/support/config.hpp> #include <boost/fusion/support/config.hpp>
#include <boost/mpl/int.hpp> #include <boost/mpl/int.hpp>
#include <boost/mpl/empty_base.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/or.hpp>
#include <boost/fusion/sequence/intrinsic_fwd.hpp> #include <boost/fusion/sequence/intrinsic_fwd.hpp>
#include <boost/fusion/sequence/intrinsic/has_key.hpp>
#include <boost/fusion/iterator/value_of_data.hpp> #include <boost/fusion/iterator/value_of_data.hpp>
#include <boost/fusion/algorithm/query/find.hpp> #include <boost/fusion/algorithm/query/find.hpp>
#include <boost/fusion/support/tag_of.hpp> #include <boost/fusion/support/tag_of.hpp>
#include <boost/fusion/support/category_of.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
@ -52,13 +57,27 @@ namespace boost { namespace fusion
template <> template <>
struct value_at_key_impl<std_pair_tag>; struct value_at_key_impl<std_pair_tag>;
} }
namespace detail
{
template <typename Sequence, typename N, typename Tag>
struct value_at_key_impl
: mpl::if_<
mpl::or_<
typename extension::has_key_impl<Tag>::template apply<Sequence, N>
, traits::is_unbounded<Sequence>
>
, typename extension::value_at_key_impl<Tag>::template apply<Sequence, N>
, mpl::empty_base
>::type
{};
}
namespace result_of namespace result_of
{ {
template <typename Sequence, typename N> template <typename Sequence, typename N>
struct value_at_key struct value_at_key
: extension::value_at_key_impl<typename detail::tag_of<Sequence>::type>:: : detail::value_at_key_impl<Sequence, N, typename detail::tag_of<Sequence>::type>
template apply<Sequence, N>
{}; {};
} }
}} }}

View File

@ -36,6 +36,8 @@ namespace boost { namespace fusion
struct associative_tag {}; struct associative_tag {};
struct unbounded_tag {};
namespace extension namespace extension
{ {
template<typename Tag> template<typename Tag>
@ -107,6 +109,13 @@ namespace boost { namespace fusion
random_access_traversal_tag random_access_traversal_tag
, typename category_of<T>::type> , typename category_of<T>::type>
{}; {};
template <typename T>
struct is_unbounded
: is_base_of<
unbounded_tag
, typename category_of<T>::type>
{};
} }
}} }}