|
Boost : |
From: sdanil (sdspam_at_[hidden])
Date: 2003-11-03 10:02:32
Hi!
In Pascal we can write following code:
procedure Foo( ch : Char )
Begin
if ( ch in [\'a\', \'b\', \'v\'..\'z\'] ) Then
begin
...
end
End;
But this syntax is unavailable in C/C++. (I know, that
we can use switch/case syntax, but it\'s awkward in many
cases)
I suggest \'one_of\' library, which provides following
code:
void foo( char ch )
{
if ( one_of( ch ) % \'a\' % \'b\' % range( \'v\',
\'z\' ) )
{
...
}
}
There are three cases of usage:
1) one_of( <value> ) % <constant>
2) one_of( <value> ) % range( <lo_constant>,
<hi_constant> )
3) one_of( <value> ) % suite( <begin_iterator>,
<end_iterator> )
All three cases can be combined in arbitrary ways.
Source code of one_of library in attachment.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk