Bonjour,
j'ai un namespace MaLib :
Voici le fichier MaLibFromString.h
comme toutes les fonctions sont template, tout le code est dans le .h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 namespace MaLib { // Conversion d'une std::string en n'importe quel type template<class T> bool fromString(const std::string & str, T & dest); // conversion d'une std::string en n'importe quel type. Il faut que le separateur soit // un espace (espace blanc ou tabulation) template<typename T> void fromString(const std::string & str, std::vector<T> & v); }
Voici le fichier MaLibSplit.h
Notez bien que la dernière fonction de MaLib::split appelle MaLib::fromString et que MaLib::fromString appelle MaLib::split
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 namespace MaLib { MaLib_API void split(const std::string & str,char delim,std::vector<std::string> & v); MaLib_API void split(const std::string & str,const std::string & delim,std::vector<std::string> & v); // conversion d'une std::string en n'importe quel type. Il faut que le separateur soit // un espace (espace blanc ou tabulation) template<typename T> void split(const std::string & str, std::vector<T> & v); } template<typename T> void MaLib::split(const std::string & str, std::vector<T> & v) { v.clear(); MaLib::fromString(str, v); }
Sous Windows visual Studio 2005 aucun problème. Tout compile et s'exécute. Sous linux, j'ai le problème : MaLib::split n'appartient pas au namespace MaLib. J'utilise gcc 4.1
Avez-vous une idée d'où pourrait provenir l'erreur de compilation ?
Merci beaucoup
Partager