Boost logo

Boost :

From: Stjepan Rajko (stipe_at_[hidden])
Date: 2007-10-15 13:23:18


Hello,

As I'm preparing the dataflow library for submission (a.k.a. signal
network gsoc project), I'm revisiting some of the design choices.
Since I'm not too experienced with generic library design, I was
wondering if anyone would share some advice on which tag dispatch
convention to use.

For my specializable functions, I adapted what is used in fusion, e.g.:

template<typename ProducerTag, ConsumerTag>
struct operation_impl;

template<>
struct operation_impl<some_producer_tag, some_consumer_tag>
{
  template<typename P, typename C>
  struct apply
  {
      typedef some_result_type type;

      static type call(P &p, C &c)
      {
        ...
      }
  };
};

and then free function `operation` extracts the tags from its
arguments, calls operation_impl, and returns the result.

Could someone tell me what the advantages/disadvantages of this
approach are compared to, say,

template<>
struct operation_impl<some_producer_tag, some_consumer_tag>
{
  // specify result type using result_type typedef or template<> struct result
  // ...

  template<typename P, typename C>
  some_result_type operator()(P &p, C &c)
  {
    ...
  };
};

, or the technique described in:
http://www.boost.org/more/generic_programming.html,

or any other tag dispatching convention I should be aware of?

Thanks in advance!

Stjepan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk