Uwe Stöhr <[EMAIL PROTECTED]> writes: > In general a document has usually not more than 10 options, so > 10 times reforming a vector should be done in less than one millisecond.
I understand. But if nobody tells you of "a better way" then you'll never grow. Anyway, thanks for persevering with me. It's been a long time since I wrote any C++ and the code I posted was full of C# syntax. At least this time I've got the thing to compile ;-) In your original code, "data" is actually an array of c-strings, rather than a vector<string>. Personally, I'd prefer to use vector<string>, but I'll leave it to you to either adapt tex2lyx or the code below :-P Kindest regards, Angus #include <algorithm> #include <string> #include <vector> using std::find; using std::string; using std::vector; namespace lyx { class element_matches { vector<string> const & data_; public: element_matches(vector<string> const & data) : data_(data) {} bool operator()(string const & opt_element) const { vector<string>::const_iterator it = std::find( data_.begin(), data_.end(), opt_element); return it != data_.end(); } }; void delete_opt(vector<string> & opts, vector<string> const & to_discard) { if (opts.empty() || to_discard.empty()) return; vector<string>::iterator new_end = std::remove_if( opts.begin(), opts.end(), element_matches(to_discard)); opts.erase(new_end, opts.end()); } } // namespace lyx