This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
gcc3.0: how to use template's?
- To: gcc-help at gcc dot gnu dot org
- Subject: gcc3.0: how to use template's?
- From: Bruno dot Voigt at ic3s dot de
- Date: Fri, 3 Aug 2001 15:44:54 +0200
Hi,
I get the following error, when I try to compile the following taglib.cpp
via g++ -c taglib.cpp
In file included from taglib.cpp:1:
taglib.h: In function `const std::string gucky::tag::const_singleTag(const
T&,
const std::string&)':
taglib.h:18: parse error before `it'
The same .cpp compiles and works just fine using MSVC6SP5
and SUN Forte C++ v6.1.
Thanky for advice,
Bruno
----
taglib.cpp:
#include "taglib.h"
----
taglib.h:
#ifndef TAGLIB_H
#define TAGLIB_H
#include <string>
#include <map>
namespace gucky {
namespace tag {
/** const_singleTag queries the given container for the given tagname
* and returns the value of the first found element.
* If several elements with the same tagname exists it is undefined which element is selected.
* @param t container to query
* @param tagname to query
* @returns the value of the element selected by given tagname or "" if tagname not present
*/
template<class T> inline const std::string const_singleTag(const T&t, const std::string& tagname)
{
const T::const_iterator it = t.find(tagname);
if (it != t.end())
return it->second;
return "";
}
}
}
#endif /* TAGLIB_H */
--
Bruno.Voigt@ic3s.de # IC3S AG # Tel. +49.4106.655.105 # Fax. +49.4109.555.550
http://www.ic3s.de # Mobile +49.700.686.00.686