Problème avec les set et la fonction transform
Bonjour,
Voilà, j'ai un petit problème avec la fonction transform pour appliquer un foncteur...
Mon code complilait lorsque j'utilisait un vecteur, mais depuis que je l'ai remplacé par un set, le compilo gueule...
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| #ifndef IMAGE_H
#define IMAGE_H
#include <iostream>
#include <string>
#include <set>
#include <iterator>
#include <cctype>
#include <algorithm>
using namespace std;
class Image{
private:
set<string> mots_cles;
string nom;
string datepdv;
float taille;
int largeur;
int hauteur;
public:
//conversion en minuscules des mots clés :
class to_lower{
public:
inline string operator()(string& s){
int cpt = 0;
while ( s[cpt] != '\0' ){
if ( ( s[cpt] >= 'A' ) && ( s[cpt] <= 'Z' ) ) s[cpt] += 32;
cpt++;
}
return(s);
}
};
inline void mots_cles_en_minuscules(){
transform(mots_cles.begin(), mots_cles.end(), mots_cles.begin(), to_lower());
}
};
#endif |
Voici l'erreur que me met le compilateur (pour info j'utilise dev C++ sous vista) :
C:\Dev-Cpp\include\c++\3.4.2\bits\stl_algo.h In function `_OutputIterator std::transform(_InputIterator, _InputIterator, _OutputIterator, _UnaryOperation) [with _InputIterator = std::_Rb_tree_const_iterator<std::string>, _OutputIterator = std::_Rb_tree_const_iterator<std::string>, _UnaryOperation = Image::to_lower]':
789 C:\Dev-Cpp\include\c++\3.4.2\bits\stl_algo.h no match for call to `(Image::to_lower) (const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
note F:\Pas musique\IUT 2A\C++\imagestl\image.h:112 candidates are: std::string Image::to_lower::operator()(std::string&)
Merci à ceux qui voudront bien me consacrer un peu de leur temps.