www.delorie.com/djgpp/bugs/show.cgi   search  
Bug 000174

When Created: 08/28/1997 19:54:57
Against DJGPP version: 2.01
By whom: rmerkel@acm.org
Abstract: causes ambiguous template instantiation errors
Including <string> causes the following error(s):

f:/djgpp/lang/cxx/std/sinst.h:62: ambiguous template instantiation for `operator
 >(const basic_string<char,string_char_traits<char> > &, const char *)' requeste
d

This is repeated for operator!=, >, >=, <, and <=.

The reason for this is that definations for these operators in
lang/cxx/std/bastring.h collide with templates in <function>

Solution added: 08/28/1997 20:01:23
By whom: rmerkel@acm.org
Remove the decl's for operator<=, !=, > and >= in lang/cxx/std/bastring.h. My
modifications to bastring.h are is included below:

<Start of file snippet>
// Main templates for the -*- C++ -*- string classes.
	...

#if	0
template <class charT, class traits>
inline bool
operator!= (const charT* lhs, const basic_string <charT, traits>& rhs)
{
  return (rhs.compare (lhs) != 0);
}

template <class charT, class traits>
inline bool
operator!= (const basic_string <charT, traits>& lhs, const charT* rhs)
{
  return (lhs.compare (rhs) != 0);
}
#endif

	...

#if	0
template <class charT, class traits>
inline bool
operator> (const charT* lhs, const basic_string <charT, traits>& rhs)
{
  return (rhs.compare (lhs) < 0);
}

template <class charT, class traits>
inline bool
operator> (const basic_string <charT, traits>& lhs, const charT* rhs)
{
  return (lhs.compare (rhs) > 0);
}

template <class charT, class traits>
inline bool
operator<= (const charT* lhs, const basic_string <charT, traits>& rhs)
{
  return (rhs.compare (lhs) >= 0);
}

template <class charT, class traits>
inline bool
operator<= (const basic_string <charT, traits>& lhs, const charT* rhs)
{
  return (lhs.compare (rhs) <= 0);
}

template <class charT, class traits>
inline bool
operator>= (const charT* lhs, const basic_string <charT, traits>& rhs)
{
  return (rhs.compare (lhs) <= 0);
}

template <class charT, class traits>
inline bool
operator>= (const basic_string <charT, traits>& lhs, const charT* rhs)
{
  return (lhs.compare (rhs) >= 0);
}
#endif

// Kludge this until g++ supports the new template overloading semantics.
#if	0		// #if !defined(FUNCTION_H)
template <class charT, class traits>
inline bool
operator!= (const basic_string <charT, traits>& lhs,
	    const basic_string <charT, traits>& rhs)
{
  return (lhs.compare (rhs) != 0);
}

template <class charT, class traits>
inline bool
operator> (const basic_string <charT, traits>& lhs,
	   const basic_string <charT, traits>& rhs)
{
  return (lhs.compare (rhs) > 0);
}

template <class charT, class traits>
inline bool
operator<= (const basic_string <charT, traits>& lhs,
	    const basic_string <charT, traits>& rhs)
{
  return (lhs.compare (rhs) <= 0);
}

template <class charT, class traits>
inline bool
operator>= (const basic_string <charT, traits>& lhs,
	    const basic_string <charT, traits>& rhs)
{
  return (lhs.compare (rhs) >= 0);
}
#endif

	...

#endif
<EOF>

Workaround added: 08/28/1997 20:03:13
By whom: rmerkel@acm.rog
A workaround, suggested to me by someone whos name I've forgotten, is to make
sure that the #include <string> is always first. This works for simple programs,
but when you start to use STL the errors come back.

Note added: 04/22/1999 09:00:15
By whom: eliz@is.elta.co.il
This should be reported to the libstdcxx maintainers.

This is not a DJGPP bug, so I'm closing it.

Closed on 04/22/1999 09:00:37: Not a DJGPP bug.
By whom: eliz@is.elta.co.il



  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2010   by DJ Delorie     Updated Jul 2010