Topic: Missing ctype member functions?


Author: dsp@bdal.de (Daniel Spangenberg)
Date: Wed, 5 Feb 2003 14:54:18 +0000 (UTC)
Raw View
Hello, C++ community!

The std::ctype facet template class provides the member functions

const charT* scan_is(mask m, const charT* low, const charT* high) const;

const charT* scan_not(mask m, const charT* low, const charT* high)
const;

which can be seen as (most probably) optimized versions of the
single-character function

bool is(mask m, charT c) const;

for random-access character sequences.

Now I was wondering, why there aren't corresponding backward scanners,
like

const charT* rscan_is(mask m, const charT* low, const charT* high)
const;
const charT* rscan_not(mask m, const charT* low, const charT* high)
const;

which would reflect the find_last_of and find_last_not_of member
functions of the std::basic_string class template. Their exist a lot of
char sequence "trimming" functions, which need both forward and backward
scanning opportunities.

My reasoning is:

1) The above mentioned existing character sequence functions scan_is()
and scan_not() seem to reflect possible optimized applications of the
is() member function other than a self-written loop - otherwise it would
be unnecessary to provide them.

2) Since their arguments can be viewed as random_access iterators (const
charT*), it would make sense, to additionally provide corresponding
backward scanning functions.

Name proposals could be either rscan_is() or scan_is_last_of() for the
counterpart of scan_is() and rscan_not() or scan_not_last_of() for the
counterpart of the scan_not() member function, but for sure their will
exist more reasonable naming proposals by others ;-)).

What is your opinion about this proposal?

Thanks,

Daniel Spangenberg




---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]