Add find support to std::string

This commit is contained in:
Baptiste Wicht 2014-02-23 16:55:25 +01:00
parent 6448a699fc
commit a3bb9c5a41

View File

@ -28,6 +28,8 @@ public:
typedef CharT* iterator; typedef CharT* iterator;
typedef const CharT* const_iterator; typedef const CharT* const_iterator;
static constexpr const size_t npos = -1;
private: private:
size_t _size; size_t _size;
size_t _capacity; size_t _capacity;
@ -227,6 +229,16 @@ public:
return _data[i]; return _data[i];
} }
size_t find(char c) const {
for(size_t i = 0; i < size(); ++i){
if(_data[i] == c){
return i;
}
}
return npos;
}
//Operators //Operators
bool operator==(const CharT* s) const { bool operator==(const CharT* s) const {