Xeo*_*Xeo 11 c++ templates decltype visual-c++ c++11
struct X{};
template<class T>
decltype(X() == int()) f(T const&){ return true; }
int main(void) {
X x;
f(x);
}
Run Code Online (Sandbox Code Playgroud)
为什么,为什么?有没有operator==
定义任何地方!
我真的想了解这里发生了什么,提供有关MS Connect的详细错误报告.我的精神错乱的旅程大约始于这里在休息室<C++>聊天室...
(注意:GCC和Clang 都不接受此代码.)
哦,顺便说一句,添加私有X(int)
ctor会导致编译失败:
struct X{
X(){}
private:
X(int);
};
template<class T>
decltype(X() == int()) f(T const&){ return true; }
int main(void) {
X x;
f(x);
}
Run Code Online (Sandbox Code Playgroud)
输出:
1>src\main.cpp(12): error C2248: 'X::X' : cannot access private member declared in class 'X'
1> src\main.cpp(4) : see declaration of 'X::X'
1> src\main.cpp(1) : see declaration of 'X'
Run Code Online (Sandbox Code Playgroud)
您使用的是什么版本的MS VC++?
无论它有什么价值,VC++ 11 Beta拒绝你的代码:
trash.cpp(8): error C2893: Failed to specialize function template ''unknown-type' f(const T &)'
With the following template arguments:
'X'
Run Code Online (Sandbox Code Playgroud)
我不知道这就是我所称之为最有用的或错误提示信息,但被拒绝的代码.
在这种情况下,我认为提交错误报告可能会完成很少(如果有的话).我期望的反应基本上是:"已经在VC++ 11中得到修复.尽可能升级."
归档时间: |
|
查看次数: |
259 次 |
最近记录: |