考慮一個小的獨立的用例,其中我想確定一個類型是完全或不完全使用GCC 6.1的std ::的result_of編譯錯誤
#include <type_traits>
namespace {
struct foo {
template<class T, std::size_t = sizeof(T)>
std::false_type operator()(T&);
std::true_type operator()(...);
};
struct FooIncomplete;
}
int main() {
std::result_of<foo(FooIncomplete&)>::type();
return 0;
}
編譯沒有與gcc 4.9.3
與--std=c++11
標誌。然而,隨着gcc 6.1
和--std=c++11
它產生compilation error作爲
main.cpp: In function 'int main()':
main.cpp:17:5: error: 'type' is not a member of 'std::result_of<{anonymous}::foo({anonymous}::FooIncomplete&)>'
std::result_of<foo(FooIncomplete&)>::type();
缺少什麼我在這裏?什麼可能是一個可能的解決方法?
看起來像一個g ++迴歸 – Arunmu
@Arunmu應該g ++選擇'運算符()(...)'然後呢?它試圖製作一個不完整類型的副本 –
您是否嘗試過沒有匿名'namespace',即使用一個命名空間來代替。 – user3405291