[Boost] [Fusion] Help with tuple adapter

Hi all,
I'm having some trouble getting the boost fusion tuple adapter working (the one that makes boost::tuples into conforming sequence types). I'm assuming that the adapted tuple should now be a legal MPL sequence but mpl::is_sequence yields false and consequently mpl::for_each doesn't work on the tuple type either. The following program is an illustration of what I am trying to do. I guess I must be missing something simple?
Any help would be appreciated.
Bill
#include <iostream>
#include <typeinfo>
#include

On 1/21/2010 3:52 AM, Bill Nell wrote:
Hi all, I'm having some trouble getting the boost fusion tuple adapter working (the one that makes boost::tuples into conforming sequence types). I'm assuming that the adapted tuple should now be a legal MPL sequence but mpl::is_sequence yields false and consequently mpl::for_each doesn't work on the tuple type either. The following program is an illustration of what I am trying to do. I guess I must be missing something simple?
Any help would be appreciated.
This has come up every now and then. First of all, Fusion's definition of a "conforming MPL sequence" is one that conforms to the MPL ForwardSequence, which is the least specialized of all MPL sequences: http://tinyurl.com/ygpqr9m Notice that there is no requirement for mpl::is_sequence. My contention is that the code that relies on mpl::is_sequence is the problem, not Fusion. Either that, or update the MPL docs to add that requirement. So far, I haven't got any clear response from the MPL authors yet. Having said that, it is easy to add the specialization for all external adapted sequences. Would you like to contribute such code? Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net http://www.facebook.com/djowel Meet me at BoostCon http://www.boostcon.com/home http://www.facebook.com/boostcon

Bill Nell schrieb:
I'm having some trouble getting the boost fusion tuple adapter working (the one that makes boost::tuples into conforming sequence types). I'm assuming that the adapted tuple should now be a legal MPL sequence but mpl::is_sequence yields false and consequently mpl::for_each doesn't work on the tuple type either. The following program is an illustration of what I am trying to do. I guess I must be missing something simple?
mpl::for_each should work fine with any built-in or adapted fusion sequence. You are experiencing this problem due to fusion not specializing mpl::sequence_tag for adapted types. I committed a patch a few weeks ago that fixed this problem. Grab a copy of the trunk or the release branch and try it again. As Joel pointed out, mpl::is_sequence is not required to evaluate to mpl::true_ for fusion sequences. Although my patch has the side effect that mpl::is_sequence is true for fusion sequences now, you should not rely on this behavior. It may not be reproducible with certain toolchains and mpl's implementation might change in the future. -Christopher

On 1/22/2010 7:06 AM, Christopher Schmidt wrote:
Bill Nell schrieb:
I'm having some trouble getting the boost fusion tuple adapter working (the one that makes boost::tuples into conforming sequence types). I'm assuming that the adapted tuple should now be a legal MPL sequence but mpl::is_sequence yields false and consequently mpl::for_each doesn't work on the tuple type either. The following program is an illustration of what I am trying to do. I guess I must be missing something simple?
mpl::for_each should work fine with any built-in or adapted fusion sequence. You are experiencing this problem due to fusion not specializing mpl::sequence_tag for adapted types. I committed a patch a few weeks ago that fixed this problem. Grab a copy of the trunk or the release branch and try it again. As Joel pointed out, mpl::is_sequence is not required to evaluate to mpl::true_ for fusion sequences. Although my patch has the side effect that mpl::is_sequence is true for fusion sequences now, you should not rely on this behavior. It may not be reproducible with certain toolchains and mpl's implementation might change in the future.
Ah yeah, I forgot about that! Thanks as always, Christopher! Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net http://www.facebook.com/djowel Meet me at BoostCon http://www.boostcon.com/home http://www.facebook.com/boostcon
participants (3)
-
Bill Nell
-
Christopher Schmidt
-
Joel de Guzman