|
Boost : |
From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-02-17 14:01:32
Joel de Guzman wrote:
> Hi,
>
> In the variant docs, in the make_variant_over section
> (Using a type sequence to specify bounded types), it is
> not clear what MPL sequence concept it is referring to.
>
> I was hoping it is a Forward Sequence, but I realized that
> when I try to use make_variant_over with a Forward Sequence,
> it fails trying to use mpl::clear, which hints that
> make_variant_over requires an MPL Extensible Sequence.
> This is rather undesirable. Is there a reason why this is so?
> Can't we lessen the requirement? The situation makes it not
> possible to use mpl views or fusion views for example.
Well, one could slowly but surely create an extensible sequence with
mpl::copy.
I had a quick take at this one to make things work without wasting
compile time, see attached patch (tested with GCC4).
Regards,
Tobias
Index: variant.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/variant/variant.hpp,v
retrieving revision 1.97
diff -u -r1.97 variant.hpp
--- variant.hpp 5 Jun 2006 02:00:58 -0000 1.97
+++ variant.hpp 17 Feb 2007 18:38:01 -0000
@@ -68,11 +68,12 @@
#include "boost/mpl/deref.hpp"
#include "boost/mpl/pair.hpp"
#include "boost/mpl/protect.hpp"
-#include "boost/mpl/push_front.hpp"
#include "boost/mpl/same_as.hpp"
#include "boost/mpl/size_t.hpp"
#include "boost/mpl/sizeof.hpp"
-#include "boost/mpl/transform.hpp"
+#include "boost/mpl/transform_view.hpp"
+#include "boost/mpl/joint_view.hpp"
+#include "boost/mpl/single_view.hpp"
#include "boost/mpl/assert.hpp"
///////////////////////////////////////////////////////////////////////////////
@@ -114,10 +115,8 @@
{
private: // helpers, for metafunction result (below)
- typedef typename mpl::transform1<Sequence, F>::type transformed_;
- typedef typename mpl::max_element<transformed_
-
- >::type max_it;
+ typedef mpl::transform_view<Sequence, F> transformed_;
+ typedef typename mpl::max_element<transformed_>::type max_it;
public: // metafunction result
@@ -216,12 +215,10 @@
{
private: // helpers, for metafunction result (below)
- typedef typename mpl::eval_if<
+ typedef typename mpl::if_<
NeverUsesBackupFlag
- , mpl::identity< Types >
- , mpl::push_front<
- Types, backup_holder<void*>
- >
+ , Types
+ , mpl::joint_view< mpl::single_view< backup_holder<void*> >, Types>
>::type types;
typedef typename max_value<
@@ -943,30 +940,30 @@
::boost::mpl::not_< mpl::empty<specified_types> >::value
));
- typedef typename mpl::eval_if<
+ typedef typename mpl::if_<
is_recursive_
- , mpl::transform<
+ , mpl::transform_view<
specified_types
, mpl::protect<
detail::variant::quoted_enable_recursive<wknd_self_t>
>
>
- , mpl::identity< specified_types >
+ , specified_types
>::type recursive_enabled_types;
public: // public typedefs
- typedef typename mpl::transform<
+ typedef mpl::transform_view<
recursive_enabled_types
, unwrap_recursive<mpl::_1>
- >::type types;
+ > types;
private: // internal typedefs
- typedef typename mpl::transform<
+ typedef mpl::transform_view<
recursive_enabled_types
, mpl::protect< detail::make_reference_content<> >
- >::type internal_types;
+ > internal_types;
typedef typename mpl::front<
internal_types
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk