Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 06/08/2010, à 15:29

CasseTaTele

[Resolu] TagLib: no matching function for call to ‘std::basic_string

Bonjour,

en utilisant la TagLib, je n'arrive pas à récupérer le nom de l'album dans un objet "string",
pourtant si je l'affiche avec un cout ça marche....


voici le code :

void Collection::RetrieveCollectionTag()
{	
	int nbtracks;
	string albname;
	vector<string>::iterator itf=filelist.begin();
	FileRef f(itf->c_str());
	
        Tag *tag = f.tag();
	
	albname = string( tag->album() );

....

ça plante sur la dernière ligne " albname = string( tag->album() ); "
lors de la compile avec ce message:

sebastien@sebastien-desktop:~/code/mp3tag$ make
g++ -c collection.cpp
collection.cpp: In member function ‘void Collection::RetrieveCollectionTag()’:
collection.cpp:111: error: no matching function for call to ‘std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(TagLib::String)’
/usr/include/c++/4.4/bits/basic_string.tcc:220: note: candidates are: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(typename _Alloc::rebind<_CharT>::other::size_type, _CharT, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/c++/4.4/bits/basic_string.tcc:213: note:                 std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/c++/4.4/bits/basic_string.tcc:206: note:                 std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, typename _Alloc::rebind<_CharT>::other::size_type, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/c++/4.4/bits/basic_string.tcc:194: note:                 std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&, typename _Alloc::rebind<_CharT>::other::size_type, typename _Alloc::rebind<_CharT>::other::size_type, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/c++/4.4/bits/basic_string.tcc:184: note:                 std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&, typename _Alloc::rebind<_CharT>::other::size_type, typename _Alloc::rebind<_CharT>::other::size_type) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/c++/4.4/bits/basic_string.tcc:170: note:                 std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/c++/4.4/bits/basic_string.tcc:178: note:                 std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/c++/4.4/bits/basic_string.h:2147: note:                 std::basic_string<_CharT, _Traits, _Alloc>::basic_string() [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
collection.cpp:117: error: no matching function for call to ‘std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(TagLib::String)’
/usr/include/c++/4.4/bits/basic_string.tcc:220: note: candidates are: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(typename _Alloc::rebind<_CharT>::other::size_type, _CharT, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/c++/4.4/bits/basic_string.tcc:213: note:                 std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/c++/4.4/bits/basic_string.tcc:206: note:                 std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, typename _Alloc::rebind<_CharT>::other::size_type, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/c++/4.4/bits/basic_string.tcc:194: note:                 std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&, typename _Alloc::rebind<_CharT>::other::size_type, typename _Alloc::rebind<_CharT>::other::size_type, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/c++/4.4/bits/basic_string.tcc:184: note:                 std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&, typename _Alloc::rebind<_CharT>::other::size_type, typename _Alloc::rebind<_CharT>::other::size_type) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/c++/4.4/bits/basic_string.tcc:170: note:                 std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/c++/4.4/bits/basic_string.tcc:178: note:                 std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/c++/4.4/bits/basic_string.h:2147: note:                 std::basic_string<_CharT, _Traits, _Alloc>::basic_string() [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
collection.cpp:122: error: no match for ‘operator==’ in ‘(((Collection*)this)->Collection::albumlist + ((unsigned int)(((unsigned int)it) * 12u)))->Album::name == TagLib::Tag::album()’
make: *** [collection.o] Erreur 1

http://developer.kde.org/~wheeler/tagli … _1Tag.html

la fonction album() de la classe tag renvoie un virtual string, est-ce que c'est pour ça que je peux pas faire un =??
comment faire?

Dernière modification par CasseTaTele (Le 06/08/2010, à 18:33)

Hors ligne

#2 Le 06/08/2010, à 15:48

Jos31

Re : [Resolu] TagLib: no matching function for call to ‘std::basic_string

Plop

tag->album() est de type TagLib::String, et non string.
C'est pas le même type, donc tu peux pas l'affecter a la variable string album, a moins que ta variable album soit déclarée:
TagLib::String album;

Hors ligne

#3 Le 06/08/2010, à 18:33

CasseTaTele

Re : [Resolu] TagLib: no matching function for call to ‘std::basic_string

merci!
ça marche!

Hors ligne