#5414 closed Bugs (fixed)
Errors compiling a piece of fusion with phoenix. Pheonix bug?
| Reported by: | 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)
Change History (10)
by , 12 years ago
| Attachment: | dot_product_bug.cpp added |
|---|
comment:1 by , 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 , 12 years ago
This testcase is working with V3 (minor modifications for the nested result template needed)
comment:3 by , 12 years ago
| Cc: | added |
|---|---|
| Component: | spirit → phoenix |
| Resolution: | → fixed |
| Status: | new → closed |
| Version: | Boost 1.47.0 → Boost Development Trunk |
comment:4 by , 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:5 by , 12 years ago
For the record
https://svn.boost.org/svn/boost/trunk/libs/phoenix/example/function.cpp is wrong then?
linked to from the lazy function docs
https://svn.boost.org/svn/boost/trunk/libs/phoenix/doc/html/phoenix/starter_kit/lazy_functions.html
It's wrong then? :)
comment:6 by , 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 , 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 , 11 years ago
| Milestone: | To Be Determined → Boost 1.48.0 |
|---|---|
| Version: | Boost Development Trunk → Boost 1.46.0 |

Source