Question about basic_string::find

  • Permalink
  • submit to reddit
  • Email
  • Follow


Hello! I'm looking at the 2003 standard in section 21.3.6.1 on 
basic_string::find. The first method discussed there allows one to 
search a string for another string. It says that it returns a value, 
xpos, such that 

    at(xpos + I) == str.at(I) for all elements I of the string 
controlled by str.

In this situation 'str' is the string given as an argument to find. 
However, in the "Notes" section the standard says "Uses traits::eq()". 
The use of traits::eq() makes sense. Otherwise, for example, building 
case insensitive strings by providing alternate traits wouldn't work as 
expected. However, shouldn't the earlier condition really be

    traits::eq( at(xpos + I), str.at(I) ) for all elements I of the 
string controlled by str.

There seems to be a contradition here. The method is supposed to use 
traits::eq() yet it returns a value based on applications of operator==. 
Is this a standard bug or am I misunderstanding something?

Peter

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply Peter 8/23/2004 10:11:44 PM

See related articles to this posting

comp.lang.c++.moderated 10649 articles. 9 followers. Post

0 Replies
172 Views

Similar Articles

[PageSpeed] 22


Reply:

Similar Artilces:

Finding centroids finds too many points (and a question about order)
Hi All I have written some code whereby I take an image and I am looking for a specific event. The event is a spark. Happily, I can convert to grey and remove all values below pure white (255) and this generally leaves the spark only. I then convert to a binary image. The white blobs that represent the spark can be a bit horrible looking so I use a structured element and image dilation to bulk out and smooth out the blobs. i.e. strel('octagon',3) I can end up sometimes with one big blob (where 1 or more blobs have merged together) or I can end up with a series of blobs (whe...

FIND() question
Hi i would like a bit of help using the find function i have 2 matrixes a = [ 2,4,6; 8,10,12; 14,16,18] b = [ 2,4,8; 4,7,10; 14,23,56] i want to use the find function to find out how many variables in the first column of each of the two matrixes so that for this example the answer would 2 ( 2 and 14 in first col for oth matrixes) how do i go about thsi? Thanks ive tried find(a(:,1) = b(:,1)) but this does not work :( "Fraser Dickson" <fraser.dickson@gmail.com> wrote in message <hmo0ma$apf$1@fred.mathworks.com>...

Find All Question
At one time I knew of a scrpt that would search the entire data base for a key word in all the fields that were designated in the script... I think they included the && but for the life of me I cannot remember how to set it up. Example Presidents telephone number, VP Tel No., Asst. Tel. No. So if I would do a FIND and enter the telephone number it would search through all the telephone fields and provide the answer I was seeking. Thanks in ADVANCE.... Jace jas wrote: > At one time I knew of a scrpt that would search the entire data base for a > key word in all the fie...

Find Question
Hi All, I am trying to write a find command that will list all jpg or gif files under my home direcotry. I tried the following: find . -type f -name '*.{gif,jpg}' -print but did not return anything. The second try was: find . -type f -name '*.gif' -o -name '*.jpg' -print but this would only return the jpg files, not gif ones. What am I doing wrong? Regards, George On 2008-04-01, George <me@me.com> wrote: > > > Hi All, > > I am trying to write a find command that will list all jpg or gif files > under my home direcotry. I tried the follo...

question about find
I have the following script to delete some log files: 1 #! /usr/bin/ksh 2 #delete collection files 3 LogCollDir=/data/ 4 BackUpDays=3 5 FilePref=collection.log 6 nice -19 find ${LogCollDir} -name "${FilePref}.??????????" -mtime +${BackUpDays} -exec rm -f {} \; & 7 8 #Remove old activity log files. 9 #Only the most recent one is left 10 ActLog=/data/act_*.log 11 nice -19 ls -t ${ActLog} | nawk '{ if ( NR != 1 ) { system("rm -f " $0) } }'& The script runs every night and sometimes I get an error like: find: stat() error /data/act_...

find() question
I want to overload the std::find so i don't have to write array.begin(), array.end() everytime. so the following is my solution: template <template <typename EleT> class ContainerT, typename ElementT> typename ContainerT<ElementT>::iterator // return type find( const ContainerT<ElementT>& container, const ElementT& element) { return std::find(container.begin(), container.end(), element); } But I got const type conversion error from the overloaded find above. ...

find question again
Hello, I have a list of .php files in one directory called news/. the naming convention for these files is like this 103_ds_13998.php 15_ds_24930.php 26_ds_53237.php 36_ds_24913.php 45_ds_39596.php 61_ds_37034.php 70_ds_23038.php 103_ds_14199.php 15_ds_24932.php 26_ds_53348.php 36_ds_24916.php 45_ds_39608.php 61_ds_37595.php 70_ds_25378.php 103_ds_14457.php 15_ds_24996.php 26_ds_53451.php 36_ds_24963.php 45_ds_39612.php 61_ds_37617.php 70_ds_28041.php 103_ds_14532.php 15_ds_25045.php 26_ds_53608.php 36_ds_25033.php 45_ds_39689.php 61_ds_37772.php 70_ds_30527.php 103_ds...

find question
G'day, What is the trick when using find in order to be able to extract a portion of data from a matrix. For example, I have a matrix (n,10). I can use find to identify specific data of interest e.g. [wI]=find(combined_data(:,2)==1 | combined_data(:,2)==2 | combined_data(:,2)==3); ws = combined_data(:,7); wd = combined_data(:,8); dur = combined_data(:,9); ws=ws(wI); wd=wd(wI); dur=dur(wI); WD=[ws wd dur]; However, in this example I am having to select specific columns of data (2nd line), apply the index to each of those columns (3rd line) and then rebuild the new matrix. Is there a ...

More findings and questions
I've looked into my problem some more and I have a number of questions. First, to recap, I have a UDP app in which I am evidently calling sendto() too quickly, resulting in packets being overwritten and lost. I put together a test app in which I call sendto() in a loop. I verified that this duplicates the problem. Using this app, I can see that if I call sendto() twice, one right behind the other, the first gets overwritten. This means (I think) that sendto() does not queue up more than one packet at a time. Is there a way to configure WinSock to queue up more than one pack...

[BASH]
Hi! I need this pair of scipt in bash, are you able to help me? 1) Find all the files with a specific permission (for example 0644) into a directory tree. 2) Find all the files that belong to the user who execute the bash-scipt. (note that the script is executed from a program wrote in C, a kind of shell..) Excuse me for my bad english. Tank you very much. wigga On Wed, 09 Jun 2004 19:42:24 GMT, wigga <wigga@email.it> wrote: > > > Hi! > I need this pair of scipt in bash, are you able to help me? > 1) Find all the files with a specific permission (for example 0644) i...

simple question (couldn't find in FAQ couldn't find with google search)
hey, this is a simple question which I was surprised that I couldn't find after reading the mutt manual and a google search... how exactly do you get a split screen, so that the top shows the message you are on, and the bottom gives you a preview? I would think the obvious choice for a config option would be set split_screen=<size> or somesuch, but apparently not. Could someone post the correct usage for the sake of me and other googling people to come? thanks, jon On 29 Dec 2003 21:27:19 -0800, jonathan wrote: > how exactly do you get a split screen, so ...

19990823: General announcements. Goedel's question: if a theorem has a proof of length at most n, can we find it in time O(n^2)? Another question on what can be computed in limited time and sp
19990823: General announcements. Goedel's question: if a theorem has a proof of length at most n, can we find it in time O(n^2)? Another question on what can be computed in limited time and space. Overview of related topics from courses on algorithms, theory of computation, formal logic. Definition of composite. Definition of prime. Examples. The primality problem. Some representations of integers: decimal; binary; unary; factored. The importance of specifying the input representation. Simple algorithm for the primality problem. Time for dividing n-digit numbers. Overall time for simple al...

find Question #4
I need to find files that have been modified in the last 7 days, but I want to exclude any that have been modified today. I been fartin' and foolin' with -mtime and -newer to no avail. Ideas? Thanks On Thu, 30 Oct 2003 13:45:51 GMT, secheese <secheese@hotmail.com> wrote: >I need to find files that have been modified in the last 7 days, but I >want to exclude any that have been modified today. I been fartin' and >foolin' with -mtime and -newer to no avail. Ideas? > >Thanks Hmmm... I wonder if I can answer this myself. I'll try: -mtime 1 -mtim...

find command questions
hello , I have a file that contains file names that I need to find , I was wondering if the find command has the abilty to read a file as the pattern to look for ....... Right now this is my workaround : QT_FILE=$1 for x in ` cat customer/QUOTES/$QT_FILE | nawk '{ print $1 }' ` do find ./src ./customer -name $x done What I was hoping to have was something like : find . -name "`cat file_that_contains_files_to_look_for`" Thanks ..... In article <YZEjb.92922$PD3.4887434@nnrp1.uunet.ca>, Mariusz Malogrosz <mariuszm@tecsys.com> wrote: >hello , > >...

find question 156767
I have 2 databases, ORDERS and RECEIVED. Both have the catalog number of the items ordered. cat# I want to find out which items have not arrived yet. In ORDERS I make a script that loops through all the records (line items) , picks up the cat# and then goes over to RECEIVED and loops through all the records looking for a match for cat#. For the inner loop I suppose I could use FIND ...BUT what is the result code name? Is there a boolean script variable like FOUND? Or better still, if a relationship is established on that field cat# , is there a built-in function that will say whethe...

find command question
Hi: To find a file(starting from folder /usr/) in my computer, I used to do: find /usr/ -name "foo.dat" I don't know why today it doesn't work. It says: find: /usr/share/ssl/CA: Permission denied I switched to root user, still doesn't work. I am puzzled. Thank you very much for your help. Best Regards, Xiaoshen -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wed, 14 Jan 2004 11:29:26 +0000, Xiaoshen Li <xli6@gmu.edu> wrote: > Hi: > > To find a file(starting from folder /usr/) in my computer, I used to do: > find /usr/ -name "foo.dat&quo...

String Finding Question
The C++ "find" functions seem more cumbersome than their C ancestors. To me, string::find is more difficult to use than, say, strchr. For example, char *ptr = strchr("AEMT", 'A'); if(ptr != NULL) do_something_if_found; else do_not_found; Is there a simpler C++ way to code the following? std::string valids = "AEMT"; size_t idx = valids.find('A'); if(idx != string::npos) do_something_if_found; else do_not_found; On 16.06.13 19.24, Mike Copeland wrote: > The C++ &...

Question on finding root?
P = 11; T = 321; F = 100; i = 1:9; z_i = [0.8345 0.0046 0.0381 0.0163 0.0050 0.0074 0.0287 0.0220 0.0434]; K_i = [3.090 1.650 0.720 0.390 0.210 0.175 0.093 0.065 0.036]; solvingV = solve('((z_i*K_i*F)/(V*(K_i-1)+F)) - 1','V'). I have to find the value of V (or root) in the equation: ((z_i*K_i*F)/(V*(K_i-1)+F)) - 1. I can use a .m file that uses the Newton-Raphson method to solve for the root but I don't know how to do that because I always get an error or an absurd value. V has to be 0 < V < 100. These are the codes I have been trying: function y = equatio...

string find question
With this testprogram: #include <iostream> #include <string> using namespace std; int main() { string::size_type idx; string s1; string helloStr("hello"); cout<<"Enter a string "; cin>> s1; idx = s1.find(helloStr); if(idx == string::npos) cout<<"The string "<<helloStr<<" was not found in s1"<<endl; else cout<<"The first occurance of 'hello' in s1 is at: "<<idx<<endl; string s2("This is a test hello world!"); idx = s2.find(hell...

find prune question
Hi, In order to find all files on the system but not in the /mnt directory and whose names begin with my_file, i tried without success find / -name 'my_file*' -path '/mnt' -prune -o -print Any suggestion please ? Pascal pascal wrote: > Hi, > > In order to find all files on the system but not in the /mnt directory > and whose names begin with my_file, i tried without success > > find / -name 'my_file*' -path '/mnt' -prune -o -print > > Any suggestion please ? > > > Pascal Actually, if updatedb was run recently, u...

Question on File::Find
Hi, I am struggling to use File::Find module, the issue is, I can use with defining find function with &wanted, but not with %options, here is what I am doing my %findoption=( bydepth=>"1" , no_chdir => "1" ); push (@All,find(\%fort,"$Location")); thx -D Diana wrote: > Hi, > I am struggling to use File::Find module, > the issue is, I can use with defining find function with &wanted, but > not with %options, here is what I am doing > my %findoption=( bydepth=>"1" , no_chdir => "1" ); > push (@All,find(\%...

Find question 314618
I am setting up a find for a field n_model year which displays vehicle model years as four digits. For some reason I cannot get the asterisk/wild card char to function with it. Where the only record is "1998", 1998 finds it but not 19*, *98, *99* or any other combination. Are there some limitations to the asterisk? Thanks, Bill FMP5 W98 "Bill Jaynes" wrote: > I am setting up a find for a field n_model year which displays vehicle > model years as four digits. For some reason I cannot get the > asterisk/wild card char to function with it. Where the only record is &...

tricky find question
I would like to write a "find" statement which does the following: Descend from the current directory, print all files, but ignore everything below the directories foo, bar and baz. This is how far I got: find . -print \( -name foo -o -name bar -o -name baz \) -prune This is nearly what I wanted, but it also lists directories, not only files. Now the mystery: When I extend the command to find . -type f -print \( ... \) -prune it suddenly does not prune anymore and I get files from ALL directories. What am I doing wrong? Ronald Ronald Fischer wrote: > I would like to writ...

Simple find question
Can somebody please help me with the find command using regex. For some reason it is not behaving as a regular expression should. I have a directory with files as below: $ ls -ltr | grep "TRPT" -rw------- 1 xx other 0 Oct 22 16:23 TRPT_SCH_TABLE_20072356723.xml.gz -rw------- 1 xx other 0 Oct 22 16:24 TRPTSCHTABLE_20072356723.xml.gz -rw------- 1 xx other 0 Oct 22 16:43 TRPTSCHTABLE_20072456923.xml.gz $ The name of the files begin with TRPT, have an optional _, then SCH, again an optional _ and the rest of the filename. I want to invoke find so th...