Boost logo

Boost :

From: Itay Maman (itay_maman_at_[hidden])
Date: 2001-11-27 07:01:32


I know I am taking a risk in bringing this up, since it is possible
that this very suggestion has been discussed and decided. (I did an
extensive search - which yielded nothing - but still...)

The feature I was thinking of, can be titled as 'applying an
operation on any's value' (in a type-safe way). E.g: I'd like to send
the value held by a boost::any object to cout, but I don't want to
use any_cast<>, since this forces me to add a specific any_cast<>
call for each type.

The client code should look something along these lines:

     struct my_functor {
        ....
     }

     boost::any a1('A');
     a1.apply_the_operation(my_functor());

     a1 = 222;
     a1.apply_the_operation(my_functor());

If my_functor is defined to send its operand to cout, then I would
expect the above code to yield the following output:
  A
  222

Has this been discussed yet?

(I have written an any implementation which supports that, but having
read Henney's views on adding template parameters to any, I am not
sure he's going to like it).


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