This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[Q] operators and conversion problem
- To: gcc at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org
- Subject: [Q] operators and conversion problem
- From: Miljenko Cvjetko <m dot cvjetko_njet_spam at rt dot e-technik dot uni-erlangen dot de>
- Date: Fri, 12 May 2000 18:19:45 +0200
- Newsgroups: comp.lang.c++
- Organization: gcl++ Library Development
- Reply-To: m dot cvjetko_njet_spam at rt dot e-technik dot uni-erlangen dot de
/*
newsgroups:
comp.lang.c++
comp.lang.c++.moderated
mailing lists:
gcc@gcc.gnu.org
gcc-bugs@gcc.gnu.org
[Q] operators and conversion problem
Hi again!
Shouldn't ints (1 and 2) in lines 44 and 45 be converted to X<int> and
then applied operator+ ???
Is this a bug or is this my error??
Thanx a lot
miljenko
*/
template <class T>
class X
{
public:
X<T>(){};
X<T>(const X<T>& x){};
// conversion T in X<T>
X<T>(const T& t){};
X<T>& operator+= (const X<T>& x) { return *this; };
};
template <class T>
X<T>
operator+ (const X<T>& lhs, X<T>& rhs) { return X<T>(lhs) += rhs; };
int main()
{
X<int> xi1;
X<int> xi2;
xi1 + 1;
xi2 + 2;
return 0;
}
/*
gcl@robby:~/gcl/src/example/core/Math/Discrete/Set > less
../../../../Test/syntax_standard_conformance/TO_REPORT.cpp
gcl@robby:~/gcl/src/example/core/Math/Discrete/Set > g++ -v BUG_test.cpp
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
gcc version 2.95.2 19991024 (release)
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/cpp -lang-c++ -v -D__GNUC__=2
-D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -D__ELF__ -Dunix
-D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix
-D__linux -Asystem(posix) -D__EXCEPTIONS -Acpu(i386) -Amachine(i386)
-Di386 -D__i386 -D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__
-D__pentiumpro -D__pentiumpro__ BUG_test.cpp /tmp/cc5je9dn.ii
GNU CPP version 2.95.2 19991024 (release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../include/g++-3
/usr/local/include
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../i686-pc-linux-gnu/include
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/include
/usr/include
End of search list.
The following default directories have been omitted from the search
path:
End of omitted list.
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/cc1plus /tmp/cc5je9dn.ii
-quiet -dumpbase BUG_test.cc -version -o /tmp/ccoSeXeI.s
GNU C++ version 2.95.2 19991024 (release) (i686-pc-linux-gnu) compiled
by GNU C version 2.95.2 19991024 (release).
BUG_test.cpp: In function `int main()':
BUG_test.cpp:44: no match for `X<int> & + int'
BUG_test.cpp:45: no match for `X<int> & + int'
*/