C++v2,96:member template conversion not implicit
Larry Evans
jcampbell3@prodigy.net
Sun Jul 2 07:19:00 GMT 2000
The member template conversion operator in the following code should be
implicitly called in the
following code, but it's not.
------------------ cut here ----------------
make bugrep
uname -a
Linux localhost.localdomain 2.2.13-4mdk #1 Tue Sep 7 18:23:11 CEST 1999
i586 unknown
../../../snap/bin/g++ -v
Reading specs from
../../../snap/bin/../lib/gcc-lib/i586-pc-linux/2.96/specs
gcc version 2.96 20000625 (experimental)
../../../snap/bin/g++ -E -imacros .mac main.cpp
# 1 "main.cpp"
enum
TestEnumFlag
{ FlagNo
, FlagYes
};
struct
SubjTop
{
};
template
<TestEnumFlag TEST_FLAG
>
struct
Subj1
: public SubjTop
{
template
<TestEnumFlag AS_TF
>
operator
Subj1<AS_TF>&
(void)
{ SubjTop&t=*this
; return static_cast<Subj1<AS_TF>&>(t)
;}
};
int
main(void)
{
; typedef Subj1<FlagYes> Subj1Yes
; typedef Subj1<FlagNo> Subj1No
; Subj1Yes x
; Subj1No&y=x
; return 0
;}
../../../snap/bin/g++ -c -imacros .mac main.cpp
main.cpp: In function `int main ()':
main.cpp:38: conversion from `main ()::Subj1Yes' to non-scalar type
`Subj1<FlagNo>' requested
main.cpp:38: cannot initialize `main ()::Subj1No &' from `main
()::Subj1Yes'
make: *** [compile] Error 1
More information about the Gcc-bugs
mailing list