This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hello,
I have attached a patch along with a test case for the find_end()
function.
I intend implementing basic_string<>::rfind() using this version if and
when this piece of code is committed.
--
-Dhruv Matani.
http://www.geocities.com/dhruvbird/
The price of freedom is responsibility, but it's a bargain, because
freedom is priceless. ~ Hugh Downs
Attachment:
patch_stl_algo.h_dhruv_16122004
Description: Text document
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int
find_end_wrapper(std::string src, std::string f)
{
int pos = find_end(src.begin(), src.end(), f.begin(), f.end())
- src.begin();
return pos;
}
int main()
{
std::string src = "This is the string to be used for testing the "
"find_end() functions defined in the standard header <algorithm>.";
cerr<<"String not found if return value is: "<<src.size()<<endl;
// 99
cerr<<find_end_wrapper(src, "algorithm")<<endl;
// 109
cerr<<find_end_wrapper(src, ".")<<endl;
// 0
cerr<<find_end_wrapper(src, "This")<<endl;
// 110
cerr<<find_end_wrapper(src, "this")<<endl;
// 19
cerr<<find_end_wrapper(src, "to b")<<endl;
}
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |