/** * * @file TestFunctor.cpp * * @authors M. Laporte, D. Mathieu * * @date 07/12/2011 * * @version V1.0 * * @brief Premier functor * **/ #include <iostream> #include <string> #include <cctype> // tolower(), toupper() #include <cassert> using namespace std; namespace { class ToLower { public : virtual ~ToLower (void) {} virtual int operator () (int caract) const { return tolower (caract); } // operateur() }; // ToLower string & moulinette (string & str, const ToLower & transf) { for (string::size_type i (str.size ()); i--; ) str [i] = transf (str [i]); return str; } // moulinette() void testFunctor (void) { cout << "Functor : "; string ligne ("AZECv qrgWSg wrV wfdgWFDHG wdfGWXCV"); string minusc ("azecv qrgwsg wrv wfdgwfdhg wdfgwxcv"); assert (minusc == moulinette (ligne, ToLower())); cout << "OK\n"; } // testFunctor() } // namespace int main (void) { /* */ testFunctor(); /* */ return 0; } // main()