unused entries in zip

[SVN r37150]
This commit is contained in:
Dan Marsden
2007-03-06 21:37:26 +00:00
parent fad42340ad
commit d1cc519a44
11 changed files with 163 additions and 12 deletions

View File

@ -15,6 +15,11 @@
#include <boost/type_traits/remove_reference.hpp> #include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/is_reference.hpp> #include <boost/type_traits/is_reference.hpp>
#include <boost/mpl/assert.hpp> #include <boost/mpl/assert.hpp>
#include <boost/fusion/support/unused.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
@ -27,7 +32,9 @@ namespace boost { namespace fusion
{ {
template<typename SeqRef> template<typename SeqRef>
struct result struct result
: result_of::at<typename remove_reference<SeqRef>::type, N> : mpl::eval_if<is_same<SeqRef, unused_type const&>,
mpl::identity<unused_type>,
result_of::at<typename remove_reference<SeqRef>::type, N> >
{ {
BOOST_MPL_ASSERT((is_reference<SeqRef>)); BOOST_MPL_ASSERT((is_reference<SeqRef>));
}; };
@ -45,6 +52,11 @@ namespace boost { namespace fusion
{ {
return fusion::at<N>(seq); return fusion::at<N>(seq);
} }
unused_type operator()(unused_type const&) const
{
return unused_type();
}
}; };
} }

View File

@ -13,7 +13,11 @@
#include <boost/fusion/algorithm/transformation/transform.hpp> #include <boost/fusion/algorithm/transformation/transform.hpp>
#include <boost/type_traits/remove_reference.hpp> #include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/is_reference.hpp> #include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/assert.hpp> #include <boost/mpl/assert.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/fusion/support/unused.hpp>
namespace boost { namespace fusion { namespace boost { namespace fusion {
@ -25,7 +29,9 @@ namespace boost { namespace fusion {
{ {
template<typename SeqRef> template<typename SeqRef>
struct result struct result
: result_of::begin<typename remove_reference<SeqRef>::type> : mpl::eval_if<is_same<SeqRef, unused_type const&>,
mpl::identity<unused_type>,
result_of::begin<typename remove_reference<SeqRef>::type> >
{ {
BOOST_MPL_ASSERT((is_reference<SeqRef>)); BOOST_MPL_ASSERT((is_reference<SeqRef>));
}; };
@ -44,6 +50,10 @@ namespace boost { namespace fusion {
return fusion::begin(seq); return fusion::begin(seq);
} }
unused_type operator()(unused_type const&) const
{
return unused_type();
}
}; };
} }

View File

@ -12,6 +12,10 @@
#include <boost/fusion/iterator/deref.hpp> #include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/algorithm/transformation/transform.hpp> #include <boost/fusion/algorithm/transformation/transform.hpp>
#include <boost/fusion/sequence/conversion/as_vector.hpp> #include <boost/fusion/sequence/conversion/as_vector.hpp>
#include <boost/fusion/support/unused.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost { namespace fusion { namespace boost { namespace fusion {
@ -23,7 +27,9 @@ namespace boost { namespace fusion {
{ {
template<typename It> template<typename It>
struct result struct result
: result_of::deref<It> : mpl::eval_if<is_same<It, unused_type>,
mpl::identity<unused_type>,
result_of::deref<It> >
{}; {};
template<typename It> template<typename It>
@ -32,6 +38,11 @@ namespace boost { namespace fusion {
{ {
return fusion::deref(it); return fusion::deref(it);
} }
unused_type operator()(unused_type const&) const
{
return unused_type();
}
}; };
} }

View File

@ -20,21 +20,34 @@
#include <boost/mpl/assert.hpp> #include <boost/mpl/assert.hpp>
#include <boost/mpl/min.hpp> #include <boost/mpl/min.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost { namespace fusion { namespace boost { namespace fusion {
struct zip_view_tag; struct zip_view_tag;
namespace detail namespace detail
{ {
template<typename SeqRef, typename M>
struct get_endpoint
{
typedef typename remove_reference<SeqRef>::type Seq;
typedef typename result_of::begin<Seq>::type begin;
typedef typename result_of::advance<begin, M>::type type;
};
template<typename M> template<typename M>
struct endpoints struct endpoints
{ {
template<typename SeqRef> template<typename SeqRef>
struct result struct result
: mpl::eval_if<is_same<SeqRef, unused_type const&>,
mpl::identity<unused_type>,
get_endpoint<SeqRef, M> >
{ {
typedef typename remove_reference<SeqRef>::type Seq; BOOST_MPL_ASSERT((is_reference<SeqRef>));
typedef typename result_of::begin<Seq>::type begin;
typedef typename result_of::advance<begin, M>::type type;
}; };
template<typename Seq> template<typename Seq>
@ -50,6 +63,11 @@ namespace boost { namespace fusion {
{ {
return fusion::advance<M>(fusion::begin(seq)); return fusion::advance<M>(fusion::begin(seq));
} }
unused_type operator()(unused_type const&) const
{
return unused_type();
}
}; };
} }

View File

@ -11,6 +11,10 @@
#include <boost/fusion/sequence/view/zip_view/zip_view_iterator_fwd.hpp> #include <boost/fusion/sequence/view/zip_view/zip_view_iterator_fwd.hpp>
#include <boost/fusion/iterator/next.hpp> #include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/algorithm/transformation/transform.hpp> #include <boost/fusion/algorithm/transformation/transform.hpp>
#include <boost/fusion/support/unused.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost { namespace fusion { namespace boost { namespace fusion {
@ -22,7 +26,9 @@ namespace boost { namespace fusion {
{ {
template<typename It> template<typename It>
struct result struct result
: result_of::next<It> : mpl::eval_if<is_same<It, unused_type>,
mpl::identity<unused_type>,
result_of::next<It> >
{}; {};
template<typename It> template<typename It>
@ -31,6 +37,11 @@ namespace boost { namespace fusion {
{ {
return fusion::next(it); return fusion::next(it);
} }
unused_type operator()(unused_type const&) const
{
return unused_type();
}
}; };
} }

View File

@ -11,6 +11,10 @@
#include <boost/fusion/sequence/view/zip_view/zip_view_iterator_fwd.hpp> #include <boost/fusion/sequence/view/zip_view/zip_view_iterator_fwd.hpp>
#include <boost/fusion/iterator/prior.hpp> #include <boost/fusion/iterator/prior.hpp>
#include <boost/fusion/algorithm/transformation/transform.hpp> #include <boost/fusion/algorithm/transformation/transform.hpp>
#include <boost/fusion/support/unused.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost { namespace fusion { namespace boost { namespace fusion {
@ -22,7 +26,9 @@ namespace boost { namespace fusion {
{ {
template<typename It> template<typename It>
struct result struct result
: result_of::prior<It> : mpl::eval_if<is_same<It, unused_type>,
mpl::identity<unused_type>,
result_of::prior<It> >
{}; {};
template<typename It> template<typename It>
@ -31,6 +37,11 @@ namespace boost { namespace fusion {
{ {
return fusion::prior(it); return fusion::prior(it);
} }
unused_type operator()(unused_type const&) const
{
return unused_type();
}
}; };
} }

View File

@ -12,6 +12,10 @@
#include <boost/fusion/algorithm/transformation/transform.hpp> #include <boost/fusion/algorithm/transformation/transform.hpp>
#include <boost/fusion/sequence/intrinsic/value_at.hpp> #include <boost/fusion/sequence/intrinsic/value_at.hpp>
#include <boost/type_traits/remove_reference.hpp> #include <boost/type_traits/remove_reference.hpp>
#include <boost/fusion/support/unused.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost { namespace fusion { namespace boost { namespace fusion {
@ -24,7 +28,9 @@ namespace boost { namespace fusion {
{ {
template<typename Seq> template<typename Seq>
struct result struct result
: result_of::value_at<typename remove_reference<Seq>::type, N> : mpl::eval_if<is_same<Seq, unused_type const&>,
mpl::identity<unused_type>,
result_of::value_at<typename remove_reference<Seq>::type, N> >
{}; {};
}; };
} }

View File

@ -12,6 +12,10 @@
#include <boost/fusion/algorithm/transformation/transform.hpp> #include <boost/fusion/algorithm/transformation/transform.hpp>
#include <boost/fusion/iterator/value_of.hpp> #include <boost/fusion/iterator/value_of.hpp>
#include <boost/mpl/placeholders.hpp> #include <boost/mpl/placeholders.hpp>
#include <boost/fusion/support/unused.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost { namespace fusion { namespace boost { namespace fusion {
@ -23,7 +27,9 @@ namespace boost { namespace fusion {
{ {
template<typename It> template<typename It>
struct result struct result
: result_of::value_of<It> : mpl::eval_if<is_same<It, unused_type>,
mpl::identity<unused_type>,
result_of::value_of<It> >
{}; {};
}; };
} }

View File

@ -9,6 +9,7 @@
#define FUSION_ZIP_VIEW_23012006_0813 #define FUSION_ZIP_VIEW_23012006_0813
#include <boost/fusion/support/sequence_base.hpp> #include <boost/fusion/support/sequence_base.hpp>
#include <boost/fusion/support/unused.hpp>
#include <boost/fusion/iterator/equal_to.hpp> #include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/sequence/view/zip_view/detail/strictest_traversal.hpp> #include <boost/fusion/sequence/view/zip_view/detail/strictest_traversal.hpp>
#include <boost/fusion/sequence/view/zip_view/detail/begin_impl.hpp> #include <boost/fusion/sequence/view/zip_view/detail/begin_impl.hpp>
@ -21,6 +22,7 @@
#include <boost/fusion/sequence/intrinsic/end.hpp> #include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp> #include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/mpl.hpp> #include <boost/fusion/sequence/intrinsic/mpl.hpp>
#include <boost/fusion/algorithm/transformation/remove.hpp>
#include <boost/mpl/assert.hpp> #include <boost/mpl/assert.hpp>
#include <boost/mpl/not.hpp> #include <boost/mpl/not.hpp>
@ -73,13 +75,14 @@ namespace boost { namespace fusion {
template<typename Sequences> template<typename Sequences>
struct zip_view : sequence_base< zip_view<Sequences> > struct zip_view : sequence_base< zip_view<Sequences> >
{ {
typedef typename result_of::remove<Sequences, unused_type const&>::type real_sequences;
BOOST_MPL_ASSERT((detail::all_references<Sequences>)); BOOST_MPL_ASSERT((detail::all_references<Sequences>));
typedef typename detail::strictest_traversal<Sequences>::type category; typedef typename detail::strictest_traversal<real_sequences>::type category;
typedef zip_view_tag fusion_tag; typedef zip_view_tag fusion_tag;
typedef fusion_sequence_tag tag; // this gets picked up by MPL typedef fusion_sequence_tag tag; // this gets picked up by MPL
typedef mpl::true_ is_view; typedef mpl::true_ is_view;
typedef typename fusion::result_of::as_vector<Sequences>::type sequences; typedef typename fusion::result_of::as_vector<Sequences>::type sequences;
typedef typename detail::min_size<Sequences>::type size; typedef typename detail::min_size<real_sequences>::type size;
zip_view( zip_view(
const Sequences& seqs) const Sequences& seqs)

View File

@ -17,5 +17,6 @@
#include <boost/fusion/support/tag_of.hpp> #include <boost/fusion/support/tag_of.hpp>
#include <boost/fusion/support/deduce.hpp> #include <boost/fusion/support/deduce.hpp>
#include <boost/fusion/support/deduce_sequence.hpp> #include <boost/fusion/support/deduce_sequence.hpp>
#include <boost/fusion/support/unused.hpp>
#endif #endif

View File

@ -0,0 +1,62 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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)
==============================================================================*/
#if !defined(BOOST_FUSION_SUPPORT_UNUSED_20070305_1038)
#define BOOST_FUSION_SUPPORT_UNUSED_20070305_1038
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
# pragma warning(push)
# pragma warning(disable: 4522) // multiple assignment operators specified warning
#endif
namespace boost { namespace fusion {
struct unused_type
{
unused_type()
{
}
template <typename T>
unused_type(T const&)
{
}
template <typename T>
unused_type const&
operator=(T const&) const
{
return *this;
}
template <typename T>
unused_type&
operator=(T const&)
{
return *this;
}
unused_type const&
operator=(unused_type const&) const
{
return *this;
}
unused_type&
operator=(unused_type const&)
{
return *this;
}
};
unused_type const unused = unused_type();
}}
#if defined(BOOST_MSVC)
# pragma warning(pop)
#endif
#endif