On Mon, Sep 01, 2003 at 04:05:59PM -0600, Dave Gomboc wrote:
> [Brian McNamara]
> > do_something( adapt( 3 ) );
> > do_something( adapt( nilable<int>(3) ) );
> > do_something( adapt( foo ) ); // foo has unknown type
>
> But I'd like to write
> do_something(3);
> do_something(foo); // of type T
> do_something(bar); // of type nilable<T>
>
> Can I have my cake and eat it too? ;-)
Yes:
template <class T>
void do_something( T x ) {
do_something_helper( adapt(x) );
}
template <class T>
void do_something_helper( nilable<T> x ) {
/* actually do it */
}
(Shameless plus: Note that with FC++,
do_something = compose( do_something_helper, adapt );
or
do_something = do_something_helper ^of^ adapt;
provided that things are defined as functoids.)
--
-Brian McNamara ([EMAIL PROTECTED])
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost