Boost logo

Boost :

From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2005-07-28 15:17:14


"Rob Stewart" <stewart_at_[hidden]> wrote in message
news:200507281901.j6SJ1Z0F011364_at_weezy.balstatdev.susq.com...
> From: "Jeff Flinn" <TriumphSprint2000_at_[hidden]>
>>
>> I just found this snippet of code in one of my projects:
>>
>> #include <boost/algorithm/string.hpp>
>> #include <boost/algorithm/string/classification.hpp>
>>
>> bool NameValid( const std::string& aName )
>> {
>> using namespace boost::algorithm;
>>
>> return all( aName, !is_any_of(" -") );;
>> }
>>
>> looks familiar eh? I totally forgot about this. I haven't looked in Pavol
>> Droba's string algorithm library to see if there are additional
>> facilities
>> that cover other cases. The 'string' in Pavol's library defines string as
>> a
>> general concept and not as std::string.
>
> That expression would be easier to read with the junctions idea:
>
> none_of(aName) == any_of(" -");
>
> (Assuming all of the above syntax can be made to work!)
>
> Don't you agree?

I agree it does read better.

Using a less operator intensive approach would yield:

    none_of( aName, any_of(" -") );

or

    all( aName, is_not_any_of(" -") );

Either way I think it would be worthwhile to get Pavol's feedback here. He's
obviously dealt with many of the same issues that are being discussed in
this thread. It may make more sense to collaborate on introducing these
facilities. Either the string algorithm library could be used as a basis for
a junction library, possibly the junction library would be provided as an
enhancement to the string algorithm library.

Jeff Flinn


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