From: Vladimir Grigoriev on
I am sorry. The original code is not complete because I did not know what
part of my code generates the error. I have shown the complete problem code.
I am using VC 2005 C++ EE.

Vladimir Grigoriev

"Leigh Johnston" <leigh(a)i42.co.uk> wrote in message
news:%23pnIkpZfKHA.2184(a)TK2MSFTNGP04.phx.gbl...
> Looks ok and compiles fine for me on VC9.
>


From: Vladimir Grigoriev on
It seems like the vector uses my template minus operator.
I think that it is a bug of VC++.

Vladimir Grigoriev


From: Victor Bazarov on
Vladimir Grigoriev wrote:
> I am sorry. The initial code is nor complete. I have found that the error
> occurs when I add the following template operator
>
> template <typename T>
>
> inline const T operator -( const T &lhs, const T &rhs )
>
> {
>
> return ( T( lhs ) -= rhs );
>
> }
>
> So the code should look the following way
>
> [..]

After dropping MS-specific elements from the code I was able to compile
it with Comeau online trial. The code is fine. Consider upgrading your
compiler, maybe?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
From: Bo Persson on
Vladimir Grigoriev wrote:
> I am sorry. The initial code is nor complete. I have found that the
> error occurs when I add the following template operator
>
> template <typename T>
>
> inline const T operator -( const T &lhs, const T &rhs )
>
> {
>
> return ( T( lhs ) -= rhs );
>
> }
>

This defines an operator- for ANY type. Why do you want to do that?



Bo Persson


From: Vladimir Grigoriev on
The code must be compiled because it has no any invalid code. It is bug of
the Microsoft realization of vecotrs.

The error occurs in the followin function frim <vector>

iterator insert(iterator _Where, const _Ty& _Val)

{ // insert _Val at _Where

size_type _Off = size() == 0 ? 0 : _Where - begin();

_Insert_n(_Where, (size_type)1, _Val);

return (begin() + _Off);

}



It seems that for the statement

size_type _Off = size() == 0 ? 0 : _Where - begin();

my template minus operator is used. Instead of a size_t value _Where -
begin(); generates const inerator.



Vladimir Grigoriev

"Victor Bazarov" <v.Abazarov(a)comAcast.net> wrote in message
news:hg8dj8$l0i$1(a)news.datemas.de...
> Vladimir Grigoriev wrote:
>> I am sorry. The initial code is nor complete. I have found that the error
>> occurs when I add the following template operator
>>
>> template <typename T>
>>
>> inline const T operator -( const T &lhs, const T &rhs )
>>
>> {
>>
>> return ( T( lhs ) -= rhs );
>>
>> }
>>
>> So the code should look the following way
>>
>> [..]
>
> After dropping MS-specific elements from the code I was able to compile it
> with Comeau online trial. The code is fine. Consider upgrading your
> compiler, maybe?
>
> V
> --
> Please remove capital 'A's when replying by e-mail
> I do not respond to top-posted replies, please don't ask