This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
gcc 3.0 template problem - only for C++ professionals or a bug ?
- To: <gcc-bugs at gcc dot gnu dot org>
- Subject: gcc 3.0 template problem - only for C++ professionals or a bug ?
- From: Helmut Schröger <helmut dot schroeger at rl-ag dot de>
- Date: Mon, 23 Jul 2001 10:23:41 +0200
- Reply-To: <helmut dot schroeger at rl-ag dot de>
Hi !
Could anyone please give me a hint whats wrong with my code ?
Please do not worry about the "semantical" correctness of the
code itself (it's a just a demo) but only about getting the
followong error from the gcc 3.0 compiler:
g++ main.cpp -o main
/usr/local/gnu/include/g++-v3/bits/stl_algo.h: In function `const _Tp&
std::__median(const _Tp&, const _Tp&, const _Tp&) [with _Tp =
namespace_t]':
/usr/local/gnu/include/g++-v3/bits/stl_algo.h:1605: instantiated from
`void std::__introsort_loop(_RandomAccessIter, _RandomAccessIter, _Tp*,
_Size) [with _RandomAccessIter = std::__normal_iterator<namespace_t*,
std::vector<namespace_t, std::allocator<namespace_t> > >, _Tp = namespace_t,
_Size = int]'
/usr/local/gnu/include/g++-v3/bits/stl_algo.h:1643: instantiated from
`void std::sort(_RandomAccessIter, _RandomAccessIter) [with
_RandomAccessIter = std::__normal_iterator<namespace_t*,
std::vector<namespace_t, std::allocator<namespace_t> > >]'
main.cpp:28: instantiated from here
/usr/local/gnu/include/g++-v3/bits/stl_algo.h:48: passing `const
namespace_t'
as `this' argument of `bool namespace_t::operator<(const namespace_t&)'
discards qualifiers
/usr/local/gnu/include/g++-v3/bits/stl_algo.h:49: passing `const
namespace_t'
as `this' argument of `bool namespace_t::operator<(const namespace_t&)'
discards qualifiers
/usr/local/gnu/include/g++-v3/bits/stl_algo.h:51: passing `const
namespace_t'
as `this' argument of `bool namespace_t::operator<(const namespace_t&)'
discards qualifiers
/usr/local/gnu/include/g++-v3/bits/stl_algo.h:55: passing `const
namespace_t'
as `this' argument of `bool namespace_t::operator<(const namespace_t&)'
discards qualifiers
/usr/local/gnu/include/g++-v3/bits/stl_algo.h:57: passing `const
namespace_t'
as `this' argument of `bool namespace_t::operator<(const namespace_t&)'
discards qualifiers
The code is as follows:
#include <string>
#include <vector>
#include <algorithm>
class namespace_t
{
public:
std::string name;
bool operator<(const namespace_t&);
};
bool namespace_t::operator<(const namespace_t& y)
{
std::string xn;
std::string yn;
return xn < yn;
}
typedef std::vector<namespace_t> namespaceSequence_t;
int main(void)
{
namespaceSequence_t namespaces;
std::sort(namespaces.begin(), namespaces.end());
return 0;
}
The same code works with the Microsoft VC60 compiler. Please help !
Thank you in advance
Helmut Schröger