Boost logo

Boost :

From: Edward Diener (eddielee_at_[hidden])
Date: 2003-08-18 09:37:24


Beman Dawes wrote:
> In discussions about being able to specify a function to check the
> validity of path element names, a simple function pointer has been
> used:
>
> typedef bool (*name_check)( const std::string & name );
>
> Alternately, boost::function could be used. The boost::function docs
> mention several advantages over function pointers; the advantage that
> might particularly apply is that:
>
> "Boost.Function allows arbitrary compatible function objects to be
> targets (instead of requiring an exact function signature)."
>
> That can be a really powerful advantage in some applications, but
> usage of name checking in boost::filesystem seems likely to be
> limited to very
> simple cases where plain function pointers will do just fine. I'd
> also like to avoid the dependency on an additional library, since
> Boost regression
> test reporting breaks if boost::filesystem::path breaks.
>
> So unless someone comes forward with a killer argument, a simple
> function pointer will be used.
>
> Comments?

I disagree. You have a magnificent implementation in boost::function, which
can be bound to many different callback types, and yet you don't want to use
it simply to reduce a dependency. Why restrict the end-user to a global
function and go back to C++ programming of years ago simply because you are
afraid of being dependent on another implementation ? My callback function
may well be dependent on another class within which I may be using the
boost::filesystem, and to now have to fool around with global functions
instead of allowing a class member function to handle the callback is
archaic.

Why create event handling and callbacks via boost::function, boost::bind,
and boost::signals if Boost implementors themselves don't want to use these
ideas when they create their libraries ? It's a rhetorical question but it
is well-meant. Give the end-user the widest possible latitude, and just bite
the bullet of what you need to do to make your library as effective as it
can be. That's my opinion, for what it is worth.


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