This is an example of using TList with STL algoritms in CLING.
Value: test string #0
Value: test string #1
Value: test string #2
Value: test string #3
Value: test string #4
Value: test string #5
Value: test string #6
Value: test string #7
Value: test string #8
Value: test string #9
The string has been found: test string #4
#include <algorithm>
#include <iostream>
#include <sstream>
struct SEnumFunctor {
if (!aObj)
return false;
if (!str)
return false;
cout << "Value: " << str->String().Data() << endl;
return true;
}
};
struct SFind {
SFind(
const TString &aStr): fToFind(aStr) {
}
return !str->String().CompareTo(fToFind);
}
private:
};
void TListAndSTL()
{
ostringstream ss;
for (int i = 0; i < size; ++i) {
ss << "test string #" << i;
ss.str("");
}
for_each(stringList.
begin(), stringList.
end(), SEnumFunctor());
string strToFind("test string #4");
SFind func(strToFind.c_str());
if (!(*found)) {
cerr << "Can't find the string: \"" << strToFind << "\" in the container" << endl;
return;
}
if (!str) {
cerr << "Can't find the string: \"" << strToFind << "\" in the container" << endl;
return;
}
cout << "The string has been found: " << str->String().Data() << endl;
}
TRObject operator()(const T1 &t1) const
virtual void Add(TObject *obj)
Collectable string class.
Mother of all ROOT objects.
static constexpr double s
- Author
- Anar Manafov
Definition in file TListAndSTL.C.