C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

STL & gcc 3.4.4

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French)
View previous topic :: View next topic  
Author Message
Olivier Boudeville
Guest





PostPosted: Thu Aug 04, 2005 5:47 am    Post subject: STL & gcc 3.4.4 Reply with quote



Bonjour à tous,

j'ai mis à jour mon gcc (g++ : 3.3.6->3.4.4) et un code tout bête qui
compilait ne compile plus, sans que j'arrive à comprendre pourquoi.

C'est bête car il s'agit juste de parcourir une liste "constante"
contenant des chaînes "constantes", transmise par référence, avec un
'const_iterator' : (j'ai laissé le code tel quel pour ne pas rajouter
d'erreur, il s'agit d'une fonction utilitaire pour un système de log à
même de générer deux cibles, texte brut et document HTML)

(j'ai rajouté ----> pour indiquer la ligne qui lui pose problème)

"""
#include <string>
using std::string ;

#include <list>
using std::list ;

[...]

string Ceylan::formatStringList( const list<const string> & stringList )
throw()
{

string res ;

if ( TextDisplayable::GetOutputFormat() == TextDisplayable::html )
{
res = "
    " ;

    ----> for ( list<const string>::const_iterator it =
    stringList.begin(); it != stringList.end();
    it++ )
    res += "
  • " + ( *it ) + "</li>" ;

    res += "
" ;
}
else
{

// Raw text :

res = 'n' ;
for ( list<const string>::const_iterator it = stringList.begin(); it
!= stringList.end();
it++ )
res += "t+ " + ( *it ) + 'n' ;

}

return res ;
}
"""

L'erreur (abominable bien sûr avec la STL) qu'il me sort est la suivante :

"""
[..]/include/c++/3.4.4/ext/new_allocator.h: In instantiation of
`__gnu_cxx::new_allocator<const std::string>':
[...] endroits d'instanciation puis :
[..]/include/c++/3.4.4/ext/new_allocator.h:75: error: `const _Tp*
__gnu_cxx::new_allocator<_Tp>::address(const _Tp&) const [with _Tp =
const std::string]' and `_Tp*
-_gnu_cxx::new_allocator<_Tp>::address(_Tp&) const [with _Tp = const
std::string]' cannot be overloaded
"""

Bien sûr j'utilise des std::string "telles quelles", c'est-à-dire sans
les avoir sous-classées et sans avoir redéfini new ou quoi que ce soit
de suspect à mes yeux (à part un opérateur permettant de concaténer
std::string et (const) char * mais cela ne devrait pas avoir de lien)

Est-ce que quelqu'un comprendrait pourquoi il refuse désormais de
compiler cela, et comment je pourrais quand même lui spécifier
d'utiliser néanmoins une liste de chaînes, transmise par référence, en
déclarant modifier ni la liste ni les chaînes ?

Merci d'avance pour toute aide !

Olivier.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.