|
Boost : |
From: Darren Cook (darren_at_[hidden])
Date: 2006-04-12 20:38:18
Peter Dimov wrote:
> What I really want is this:
>
> void foo( myvec& v, const myset& s, int a )
> {
> // ...
>
> inline bool f( int x ) { return std::abs( x ) < a && s.find( x ) !=
> s.end(); }
>
> v.erase( std::remove_if( v.begin(), v.end(), f ), v.end() );
> }
>
> for obvious readability reasons. This syntax also allows me to use a more
> descriptive name instead of f, and the consistency with ordinary function
> definitions will make it easier to teach. It may be somewhat easier to parse
> or specify, but I haven't considered this in detail.
I also really like this syntax, and the other example suggested by Peter:
inline f( x, y ) { return x < y; }
It seems natural and easy to understand. I think not having to specify
parameter types when they can be worked out by the compiler is also
important.
But I'm not a compiler writer. Are there good reasons not to do it this way?
Darren
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk