|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2003-08-18 10:05:03
Beman Dawes <bdawes_at_[hidden]> writes:
> 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?
FWIW, Boost.Function is overkill for many simple cases. This might
be a case where the FS library should just provide a class with a
virtual function:
struct checker
{
virtual ~checker() {}
virtual bool operator()( std string const& ) = 0;
shared_ptr<checker> next; // suggested.
};
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk