[Fusion] Tentative of trasnform_if failed :(

The following code http://ideone.com/xYk4X doesn't compile and i cant get the why of it. The goal is to have a fusion transform_if that takes a compile-time predicates For each element int he sequence, if the predicates its true, we apply some transform on it, if not we return the element unchanged. What am I missing ?

falcou <Joel.Falcou@lri.fr> writes:
The following code
doesn't compile and i cant get the why of it.
The goal is to have a fusion transform_if that takes a compile-time predicates For each element int he sequence, if the predicates its true, we apply some transform on it, if not we return the element unchanged.
What am I missing ?
The MPL lambda template type parameter of the functor that is passed to Fusion causes the trouble. This functor is used by Fusion as a template type parameter for an internal metafunction class which turns into an (invalid) lambda expression due to the nested placeholder. Making 'preds' a metafunction class, e.g. via mpl::quote1, should make your code compile fine. -Christopher

On Tue, 19 Apr 2011 20:57:52 +0200, Christopher Schmidt
The MPL lambda template type parameter of the functor that is passed to Fusion causes the trouble. This functor is used by Fusion as a template type parameter for an internal metafunction class which turns into an (invalid) lambda expression due to the nested placeholder. Making 'preds' a metafunction class, e.g. via mpl::quote1, should make your code compile fine.
I figured that. Using mpl::lambda also fixes the problem. Glad it is only that ^^ Thanks for the insight :)

On Tue, Apr 19, 2011 at 11:57 AM, Christopher Schmidt < mr.chr.schmidt@online.de> wrote:
falcou <Joel.Falcou@lri.fr> writes:
The following code
doesn't compile and i cant get the why of it.
The goal is to have a fusion transform_if that takes a compile-time predicates For each element int he sequence, if the predicates its true, we apply some transform on it, if not we return the element unchanged.
What am I missing ?
The MPL lambda template type parameter of the functor that is passed to Fusion causes the trouble. This functor is used by Fusion as a template type parameter for an internal metafunction class which turns into an (invalid) lambda expression due to the nested placeholder. Making 'preds' a metafunction class, e.g. via mpl::quote1, should make your code compile fine.
Could this be considered a Boost.Fusion bug? Seems like it would be Boost.Fusion's job to insulate any template parameters it receives from unintentional lambda substitution. [I making this comment under the assumption that I understand the problem, which may not be the case.] - Jeff

"Jeffrey Lee Hellrung, Jr." <jeffrey.hellrung@gmail.com> writes: [...]
Could this be considered a Boost.Fusion bug? Seems like it would be Boost.Fusion's job to insulate any template parameters it receives from unintentional lambda substitution. [I making this comment under the assumption that I understand the problem, which may not be the case.]
- Jeff
Yes, this is definitely a bug in Fusion. -Christopher

On Tue, 19 Apr 2011 22:42:01 +0200, Christopher Schmidt <mr.chr.schmidt@online.de> wrote:
"Jeffrey Lee Hellrung, Jr." <jeffrey.hellrung@gmail.com> writes:
[...]
Could this be considered a Boost.Fusion bug? Seems like it would be Boost.Fusion's job to insulate any template parameters it receives from unintentional lambda substitution. [I making this comment under the assumption that I understand the problem, which may not be the case.]
- Jeff
Yes, this is definitely a bug in Fusion.
I worked around it by adding a lambda myself in transform_if so it si definetively fixable.

On Tue, Apr 19, 2011 at 2:11 PM, falcou <Joel.Falcou@lri.fr> wrote:
On Tue, 19 Apr 2011 22:42:01 +0200, Christopher Schmidt <mr.chr.schmidt@online.de> wrote:
"Jeffrey Lee Hellrung, Jr." <jeffrey.hellrung@gmail.com> writes:
[...]
Could this be considered a Boost.Fusion bug? Seems like it would be Boost.Fusion's job to insulate any template parameters it receives from unintentional lambda substitution. [I making this comment under the assumption that I understand the problem, which may not be the case.]
- Jeff
Yes, this is definitely a bug in Fusion.
I worked around it by adding a lambda myself in transform_if so it si definetively fixable.
Oh, sure, of course, but there should be nothing wrong with your original attempt, and (to me) it's pretty subtle what the problem is. I'll file a trac ticket, just so it's in the database. - Jeff
participants (3)
-
Christopher Schmidt
-
falcou
-
Jeffrey Lee Hellrung, Jr.