のVisual Studio 2010 SP1の使用:これはVC++ 2010コンパイラのバグですか?
1>C:\apps\MVS10\VC\include\vector(609): error C2593: 'operator !=' is ambiguous
1> C:\apps\MVS10\VC\include\xmemory(268): could be 'bool std::operator !=<_Ty,_Ty>(const std::allocator<_Ty> &,const std::allocator<_Ty> &) throw()'
1> with
1> [
1> _Ty=Test
1> ]
1> test.cpp(11): or 'bool operator !=<std::allocator<_Ty>>(const T &,const T &)' [found using argument-dependent lookup]
1> with
1> [
1> _Ty=Test,
1> T=std::allocator<Test>
1> ]
1> while trying to match the argument list '(std::allocator<_Ty>, std::allocator<_Ty>)'
1> with
1> [
1> _Ty=Test
1> ]
1> C:\apps\MVS10\VC\include\vector(606) : while compiling class template member function 'void std::vector<_Ty>::_Assign_rv(std::vector<_Ty> &&)'
1> with
1> [
1> _Ty=Test
1> ]
... vector(609)
は、この行に解決されます:
#include <vector>
//namespace XXX {
struct Test
{
bool operator==(const Test& r) const { return true; }
};
//}
//typedef XXX::Test Test;
template <typename T> inline bool operator!=(const T& l,const T& r)
{ return !(l==r); }
int main()
{
std::vector<Test> vt;
std::vector<Test> vt2 = std::move(vt);
return 0;
}
を
else if (get_allocator() != _Right.get_allocator())
OTOH、私がnamespace XXX
関連の行のコメントを外すと、苦情なしでコンパイルされます。
これはコンパイラのバグだと思っていますが、私はいくつかの独立した検証を探しています。
編集:ちょうど説明のために、VS2010で古いコードを初めて再コンパイルするとこの状況に遭遇しました。グローバルオペレーターは何年も前から廃止されていた(今削除された)。なぜコードが失敗したのか、他のコードが失敗したのか理解できませんでした。上のコードは、失敗したケースの私の蒸留です(明らかに、古いコードはstd::move()
への呼び出しを含んでいません)。
UPDATE: -私はMSにバグを記録し、彼らは、これは「コンパイラの次のリリースでは、」固定されていると回答私は推測のVisual C++ 11を参照してください意味:http://connect.microsoft.com/VisualStudio/feedback/details/731692/regression-involving-global-operator-and-std-vector
これを別のコンパイラで試しましたか? –
@GregHewgill:私はGCCで再現できません。 – mcmcc
@GregHewgill:前のコメントに嘘をつきましたが、私はC++ 11をサポートする便利な別のコンパイラを持っていないので、答えは「いいえ」です。 – mcmcc