Boost logo

Boost :

From: Steven Watanabe (steven_at_[hidden])
Date: 2006-09-13 15:04:47

> So far I see only that it adds more complexity.
> 1) You introduced circular dependency between to_ostream operation and arguments
> 2) The any<> now takes argument wrappers rather than a list of operations

What about this?

struct to_ostream : function<to_ostream, any_arg<0>&(any_arg<0>&, const
any_arg<1>&)> {
typedef boost::mpl::at_c<to_ostream, 0>::type ostream;
typedef boost::mpl::at_c<to_ostream, 1>::type ostreamable;

Using to_ostream directly will get both of these. Each any_arg<...>
can be used more than once:

struct plus : function<plus, any_arg<0>(const any_arg<0>&, const
any_arg<0>&)> {

At this point typedef any_arg<0> anyT; yields the original interface.

> If you need an operation that takes anys of different types why don't you do it in a straightforward manner?
> // Interface for storing reference_wrapper<ostream&> objects
> typedef any<ostream_ref_operations> ostream_ref;
> struct to_ostream
> : function<ostream_ref&(ostream_ref&, anyT const&)>
> {
> // ...
> };

In this case that works but it doesn't allow the other operations of
ostream to vary.
Further, it prevents dispatching on the ostream since I don't know that
dispatching is needed.

The main implementation problem I have is:
struct f : function<f, any_arg<0>(const any_arg<0>&, const any_arg<1>&)> {};
struct overload<f, int> {
    typedef boost::mpl::vector<
       float(int, long), //ok - we know enough to instantiate all the
operations of arg<f, 0> for float
       char(char, int), //ok - the operations for char are already
       bool(float, int) //illegal - can't instantiate all the
operations for bool
> type;

at_c<f, 1>::type doesn't know what other operations at_c<f, 0>::type uses.

In Christ,
Steven Watanabe

Boost list run by bdawes at, gregod at, cpdaniel at, john at