Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#5414 closed Bugs (fixed)

Errors compiling a piece of fusion with phoenix. Pheonix bug?

Reported by: joe@… Owned by: Joel de Guzman
Milestone: Boost 1.48.0 Component: phoenix
Version: Boost 1.46.0 Severity: Problem
Keywords: Cc: thom.heller@…

Description

Hi,

I've implemented a dot product of two fusion vectors as a phoenix 2 functor. However it doesn't compile and dies deep inside of phoenix. Is this a bug, or a misunderstanding on my part?

Thanks, Joe

Attachments (2)

dot_product_bug.cpp (2.0 KB ) - added by joe@… 12 years ago.
Source
log.txt (29.4 KB ) - added by joe@… 12 years ago.
Compilation output.

Download all attachments as: .zip

Change History (10)

by joe@…, 12 years ago

Attachment: dot_product_bug.cpp added

Source

by joe@…, 12 years ago

Attachment: log.txt added

Compilation output.

comment:1 by Joel de Guzman, 12 years ago

I suggest you use Phoenix-3 instead. See Ticket #5480. I am confident that this is no longer an issue. Please do so and tell us your experience so we can close both tickets. If it is still a problem, then let's move this tickets to Phoenix.

comment:2 by Thomas Heller, 12 years ago

This testcase is working with V3 (minor modifications for the nested result template needed)

comment:3 by Thomas Heller, 12 years ago

Cc: thom.heller@… added
Component: spiritphoenix
Resolution: fixed
Status: newclosed
Version: Boost 1.47.0Boost Development Trunk

comment:4 by joe@…, 12 years ago

What are those minor modifications?

Can you tell me what's wrong with this please? (It works for pheonix 2)

	template <typename V1, typename V2>
	struct result
	{
		// Presume that the return type is the type of the first element
		// of the first sequence argument.
		typedef typename boost::fusion::result_of::value_at<V1, boost::mpl::int_<0> >::type type;
	};

comment:6 by joe@…, 12 years ago

Still trying to get this result struct working. What's wrong with this then?

struct vector_dot_product_impl {
	template<typename V1, typename V2>
	struct result;

	template <typename This, typename V1, typename V2>
	struct result<This(V1, V2)>
	{
		// Presume that the return type is the type of the first element
		// of the first sequence argument.
		typedef typename boost::fusion::result_of::value_at<V1, boost::mpl::int_<0> >::type type;
	};

	template <typename V1, typename V2>
	typename result<V1, V2>::type operator()(V1 v1, V2 v2) const
	{
		using boost::phoenix::arg_names::_1;
		using boost::phoenix::arg_names::_2;
		using boost::fusion::fold;
		using boost::fusion::transform;
		return fold(transform(v1, v2, _1 * _2), 0.0, _1 + _2);
	}
};

Thanks!

comment:7 by anonymous, 12 years ago

It's ok. I've sussed it out. It has to be

        template<typename Sig>
        struct result;

not

        template<typename V1, typename V2>
        struct result;
]}}

comment:8 by Thomas Heller, 11 years ago

Milestone: To Be DeterminedBoost 1.48.0
Version: Boost Development TrunkBoost 1.46.0
Note: See TracTickets for help on using tickets.