/* Return that all specializations of this
allocator are interchangeable */
template <class T1, class T2>
bool operator== (const std::mbr_allocator<T1>&,
const std::mbr_allocator<T2>&) {
return true;
}
template <class T1, class T2>
bool operator!= (const std::mbr_allocator<T1>&,
const std::mbr_allocator<T2>&) {
return false;
}
The errors all look like the first in the
sequence:
c:\program files\microsoft visual studio\vc98
\include\vector(220) : error C2784: 'bool __cdecl
std::operator ==(const class std::list<_Ty,_A>
&,const class std::list<_Ty,_A> &)' : could not
deduce template argument for 'const class
std::list<_Ty,_A>
&' from 'class std::mbr_allocator<int>'
c:\program files\microsoft visual
studio\vc98\include\vector(220) : while compiling
class-template member function 'void __thiscall
std::vector<int,class std::mbr_allocator<int>
>::swap(class std::vector<int,class
std::mbr_allocator<int> > &
)'
I hope anyone can explain the cause of these
errors and can come up with a solution.
Mischa
Sent via Deja.com
http://www.deja.com/
Are you declaring your operators as const functions?
It does seem to be a problem with comparing the allocators as you say
(having peeked at vector line 220). For some reason it isn't finding
your operator== function at all, and is trying a random other one
instead (in this case the std::list one).
The problem seems to be that you've put the allocator in namespace
std, which is completely illegal C++. At the same time I suspect that
your operator== function isn't in namespace std, and hence is not
being found by argument dependent lookup on operator==. The solution:
take your allocator out of namespace std an put it in the global
namespace, or in one of your own namespaces. Put the operator== in the
exact same namespace to ensure that it is found by ADL.
Tom
Thanks very much! Your answer indeed solved the problem. Now onto the
next one...:-)