 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Thomas Maeder [TeamB] Guest
|
Posted: Thu Aug 18, 2005 8:53 pm Post subject: Re: Borland compiler bug? Problem overloading templatized me |
|
|
hall <XandreashX (AT) fy (DOT) chalmers.se> writes:
| Quote: | Is this a bug in the Borland compiler or is this the correct
behaviour?
|
To be able to tell for sure, I'd have to see a minimal, complete
program. But your description sounds as if there is indeed a bug int
the Borland compiler.
| Quote: | In either case, do you think that changing the member into a friend
function is a good workaround
|
Not just that. I think making it a non-member would be better even if
it didn't circumvent the compiler bug. It's hard to justify this
opinion, but the operation in question seems somewhat more related to
the type of the second argument than to STR.
| Quote: | or may I end up in some other problem?
|
Hardly. Most stream input operators are implemented as non-member
functions.
|
|
| Back to top |
|
 |
hall Guest
|
Posted: Fri Aug 19, 2005 6:51 am Post subject: Re: Borland compiler bug? Problem overloading templatized me |
|
|
Thomas Maeder [TeamB] wrote:
| Quote: | hall <XandreashX (AT) fy (DOT) chalmers.se> writes:
To be able to tell for sure, I'd have to see a minimal, complete
program. But your description sounds as if there is indeed a bug int
the Borland compiler.
|
Thanks for your reply, although it seems I never get my first post
right. Here is the code that I thought I added to the bottom of my first
post. There may be small differences to the code I described in the
first post, but it shows the same behaviour.
regards
hall
//----------------
#include <iostream>
struct STR
{
template <class tType> STR& operator >> ( tType & );
//template <class tType> friend STR & operator >> ( STR &, tType & );
};
template <class tType>
STR& STR::operator >>( tType & obj)
{
std::cout << "MEMBER ***** STR::operator >> (tType obj)n";
return *this;
}
//template <class tType>
//STR & operator >> ( STR & s, tType & a ){
// std::cout << "STAND-ALONE **** STR operator >> (STR &, tType &)n";
// return s;
//}
template <class tType> class Array3d;
template <class tType> STR & operator >> ( STR &, Array3d<tType> & );
template <class tType> class Array3d
{
friend STR & operator >> <>( STR & s, Array3d<tType> & a );
};
template <class tType>
STR & operator >> ( STR & s, Array3d<tType> & array )
{
std::cout << "STAND-ALONE **** STR & operator >> (STR &,
Array3d<tType> & )n";
return s;
}
int main()
{
STR in;
Array3d<int> array;
std::cout << "Operator >> for Array3dn";
in >> array;
std::cout << "Operator >> for intn";
int i(3);
in >> i;
return 0;
}
|
|
| Back to top |
|
 |
Hendrik Schober Guest
|
Posted: Fri Aug 19, 2005 7:30 am Post subject: Re: Borland compiler bug? Problem overloading templatized me |
|
|
hall <XandreashX (AT) fy (DOT) chalmers.se> wrote:
| Quote: | Thomas Maeder [TeamB] wrote:
hall <XandreashX (AT) fy (DOT) chalmers.se> writes:
To be able to tell for sure, I'd have to see a minimal, complete
program. But your description sounds as if there is indeed a bug int
the Borland compiler.
Thanks for your reply, although it seems I never get my first post
right. Here is the code that I thought I added to the bottom of my first
post. There may be small differences to the code I described in the
first post, but it shows the same behaviour.
|
Comeau Online () has this
Comeau C/C++ 4.3.3 (Aug 6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
Copyright 1988-2003 Comeau Computing. All rights reserved.
MODE:strict errors C++
to say to your code, so I'd think that, if BCC
does't accept the code, it's a bug in BCC.
(I probably wouldn't trust Comeau with my life,
but I would at least think about it...)
| Quote: | regards
hall
[...]
|
Schobi
--
[email]SpamTrap (AT) gmx (DOT) de[/email] is never read
I'm Schobi at suespammers dot org
"Coming back to where you started is not the same as never leaving"
Terry Pratchett
|
|
| Back to top |
|
 |
Hendrik Schober Guest
|
Posted: Fri Aug 19, 2005 7:39 am Post subject: Re: Borland compiler bug? Problem overloading templatized me |
|
|
Hendrik Schober <SpamTrap (AT) gmx (DOT) de> wrote:
| Quote: | [...]
Comeau Online () has this
Comeau C/C++ 4.3.3 (Aug 6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
Copyright 1988-2003 Comeau Computing. All rights reserved.
MODE:strict errors C++
to say to your code [...]
|
...which means, it found no errors. Sorry
for that.
Schobi
--
[email]SpamTrap (AT) gmx (DOT) de[/email] is never read
I'm Schobi at suespammers dot org
"Coming back to where you started is not the same as never leaving"
Terry Pratchett
|
|
| Back to top |
|
 |
hall Guest
|
Posted: Fri Aug 19, 2005 9:19 am Post subject: Re: Borland compiler bug? Problem overloading templatized me |
|
|
Hendrik Schober wrote:
| Quote: |
Comeau Online () has this
Comeau C/C++ 4.3.3 (Aug 6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
Copyright 1988-2003 Comeau Computing. All rights reserved.
MODE:strict errors C++
to say to your code, so I'd think that, if BCC
does't accept the code, it's a bug in BCC.
(I probably wouldn't trust Comeau with my life,
but I would at least think about it...)
|
But this only means that the code compiles without errors, just like it
does in both BCB6 and VS.net. It does not say which function it calls
when one writes
STR s;
Array3d<int> a;
s >> a;
does it?
I don't know much about Comeau, so please correct me if I'm wrong.
regards
hall
|
|
| Back to top |
|
 |
Hendrik Schober Guest
|
Posted: Fri Aug 19, 2005 10:10 am Post subject: Re: Borland compiler bug? Problem overloading templatized me |
|
|
hall <XandreashX (AT) fy (DOT) chalmers.se> wrote:
| Quote: | [...]
But this only means that the code compiles without errors, just like it
does in both BCB6 and VS.net. [...]
|
Ouch. I should have read more thoroughly.
Sorry.
Schobi
--
[email]SpamTrap (AT) gmx (DOT) de[/email] is never read
I'm Schobi at suespammers dot org
"Coming back to where you started is not the same as never leaving"
Terry Pratchett
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|