Boost logo

Boost Users :

From: Zeljko Vrba (zvrba_at_[hidden])
Date: 2008-07-19 11:51:59


On Sat, Jul 19, 2008 at 09:13:08PM +0800, Joel de Guzman wrote:
>
> What do you mean by transformations?
>
The OP wrote: "I'm trying to copy data between different types of fusion
sequences with limited success."

If I understand fusion correctly, all compile-time data structures (maps,
vectors, lists) are at run-time represented as structs. Is my understanding
correct?

If so, why provide anything else but vectors? [I have a bunch of other
questions, but I'll stop here for now.]

>
> Again, please define "traditional means".
>
Not using fusion.

>
> What is "rest" and why should fusion cover ML-style pattern matching?
>
The "rest" is iterators, views, algorithms, ... actually, anything but
simple tuples.

I did not say that fusion should cover ML-style pattern matching. It was more
of a curiosity in the lines of "wow, a bunch of stuff besides tuples, and I
have no idea what to do with it.. is there maybe a pattern-matching facility?
no.. ok, so what is it good for then?"

And I haven't been able to answer the last question to myself. I've browsed
through the fusion manual, I've tried to find a use for fusion on the project
that I'm currently working on (mostly algorithmical stuff), and I've failed to
find where fusion could be useful to me and how it would simplify the program.

So, since I'm unable to find a use for fusion in the stuff I'm working on,
there are two possible conclusions:

  1. The problem lies in the class of problems I'm working on, so I asked the
  question to find out to which class of problems is fusion suited to.

  2. The problem lies in me, in which case the answer to my question will give
  me a real-life example of other "thinking patterns".

>
> If anyone can suggest a motivating example and how to improve the
> docs, I'd appreciate it a lot.
>
A random page from the docs:
http://www.boost.org/doc/libs/1_35_0/libs/fusion/doc/html/fusion/container/set.html

Keys are compile-time types. What is the advantage of set over a simple struct
having exactly one element of each type? An example of what is easier achieved
this way (or even just a bunch of e.g. variables on the stack) rather than with
a struct would be helpful.

The documentation has artificial examples. Providing some context, e.g. by
describing a real-world problem which caused the algorithm / function / data
structure to be added to fusion would be helpful.

===

OK, copy-paste from some of my code:

++npeers[ret.first->first.first->vid_];
++npeers[ret.first->first.second->vid_];

ret is a return value from std::map::insert (which is a pair of iterator into
the map and boolean), where map is std::map<std::pair<S*, S*>, unsigned>

Any way of using fusion to write the above in a nicer way? Though, again, I
see no point in using fusion and heavy template machinery; using const
references is much easier:

const iterator &it = ret.first;
const S *key1 = it->first.first;
const S *key2 = it->first.second;
++npeers[key1->vid_];
++npeers[key2->vid_];

So fusion is a tuple library that is supposed to ease manipulation of tuples.
If the above code would be a bad use case for applying fusion, what would be a
GOOD use case?


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net