Home » U++ Library support » U++ Core » Some 'missing' string functions
Re: Some 'missing' string functions [message #13777 is a reply to message #13754] |
Sat, 26 January 2008 14:06   |
mdelfede
Messages: 1310 Registered: September 2007
|
Ultimate Contributor |
|
|
luzr wrote on Fri, 25 January 2008 23:09 |
Quote: |
find_first_not_of(), find_first_of(), find_last_not_of()
|
BTW, do you know whether STL somehow optimizes these?
I am rather thinking about adding "Filter" variant here...
void FindFirst(int (*filter)(int c), int from = 0)
|
you'd need also
void FindFirst(int (*filter)(char *s), int from = 0)
as std:: has also such functions. For example :
int i = s.find_first_not_of("ab", 5)
gives the index of first character in s starting from index 5 which is neither 'a' nor 'b'.
That's useful to skip some character in a line, used for example in Astyle to skip spaces and tabs :
int i = s.find_first_not_of(" \t", 5)
The filter idea is not bad at all, and you could also add some wrapper for simpler cases.
BTW, another stuf I think is missing is a constant that is returned when no match is found. std:: uses string::npos, which should have a value of -1 but makes code reading easer.
Ciao
Max
|
|
|
 |
|
Some 'missing' string functions
By: mdelfede on Fri, 25 January 2008 12:37
|
 |
|
Re: Some 'missing' string functions
By: mirek on Fri, 25 January 2008 23:05
|
 |
|
Re: Some 'missing' string functions
By: mirek on Fri, 25 January 2008 23:09
|
 |
|
Re: Some 'missing' string functions
By: mdelfede on Sat, 26 January 2008 14:06
|
 |
|
Re: Some 'missing' string functions
By: mirek on Sat, 26 January 2008 14:24
|
 |
|
Re: Some 'missing' string functions
By: mdelfede on Sat, 26 January 2008 14:49
|
 |
|
Re: Some 'missing' string functions
By: phirox on Fri, 06 June 2008 23:21
|
 |
|
Re: Some 'missing' string functions
By: mirek on Sat, 07 June 2008 16:12
|
 |
|
Re: Some 'missing' string functions
By: mr_ped on Mon, 09 June 2008 08:32
|
 |
|
Re: Some 'missing' string functions
By: hans on Mon, 09 June 2008 10:51
|
 |
|
Re: Some 'missing' string functions
By: mirek on Mon, 09 June 2008 14:27
|
 |
|
Re: Some 'missing' string functions
By: mirek on Mon, 09 June 2008 14:28
|
 |
|
Re: Some 'missing' string functions
By: captainc on Thu, 28 August 2008 10:13
|
 |
|
Re: Some 'missing' string functions
By: mirek on Thu, 28 August 2008 15:19
|
Goto Forum:
Current Time: Mon Aug 25 06:14:25 CEST 2025
Total time taken to generate the page: 0.06503 seconds
|