2012-12-17 37 views
3

在試圖用gcc 4.7.2嘗試build boost mirror時,我遇到了這個錯誤,但奇怪的是,我看到了this documentationhas :: std :: has_nothrow_default_constructor已被移動/更改?

是否已移動/更改了::std::has_nothrow_default_constructor

In file included from /home/kfeng/src/mirror-lib/include/mirror/type_traits.hpp:20:0, 
       from /home/kfeng/src/mirror-lib/include/mirror/mirror_base.hpp:38, 
       from /home/kfeng/src/mirror-lib/include/mirror/mirror.hpp:16, 
       from /home/kfeng/src/mirror-lib/src/mirror/example/all_member_variables.cpp:10: 
/home/kfeng/src/mirror-lib/include/mirror/type_traits/is_default_constructible.hpp:31:2: error: ‘has_nothrow_default_constructor’ is not a member of ‘std’ 
/home/kfeng/src/mirror-lib/include/mirror/type_traits/is_default_constructible.hpp:28:9: error: parse error in template argument list 
/home/kfeng/src/mirror-lib/include/mirror/type_traits/is_default_constructible.hpp:31:43: error: expected ‘{’ before ‘::’ token 
/home/kfeng/src/mirror-lib/include/mirror/type_traits/is_default_constructible.hpp:31:51: error: expected initializer before ‘||’ token 
In file included from /home/kfeng/src/mirror-lib/include/mirror/type_traits.hpp:21:0, 
       from /home/kfeng/src/mirror-lib/include/mirror/mirror_base.hpp:38, 
       from /home/kfeng/src/mirror-lib/include/mirror/mirror.hpp:16, 
       from /home/kfeng/src/mirror-lib/src/mirror/example/all_member_variables.cpp:10: 
/home/kfeng/src/mirror-lib/include/mirror/type_traits/is_copy_constructible.hpp:31:2: error: ‘has_nothrow_copy_constructor’ is not a member of ‘std’ 
/home/kfeng/src/mirror-lib/include/mirror/type_traits/is_copy_constructible.hpp:28:9: error: parse error in template argument list 
/home/kfeng/src/mirror-lib/include/mirror/type_traits/is_copy_constructible.hpp:31:40: error: expected ‘{’ before ‘::’ token 
/home/kfeng/src/mirror-lib/include/mirror/type_traits/is_copy_constructible.hpp:31:48: error: expected initializer before ‘||’ token 
make[2]: *** [src/mirror/example/CMakeFiles/mirror-all_member_variables.dir/all_member_variables.cpp.o] Error 1 
make[1]: *** [src/mirror/example/CMakeFiles/mirror-all_member_variables.dir/all] Error 2 
make: *** [all] Error 2 

ANSWER使用Pubby注以下

像這樣的東西應該用gcc 4.7.2工作 - 我將提交一個補丁,讓維護人員決定如何最好地處理它。

template <typename T> 
struct is_default_constructible 
    : std::integral_constant< 
     bool, 
     ::std::has_trivial_default_constructor<T>::value || 
#if __cplusplus>=201103L 
     ::std::is_nothrow_default_constructible<T>::value || 
#else 
     ::std::has_nothrow_default_constructor<T>::value || 
#endif 
     mirror::_class::_<T>::has_default_ctr::value> 
{ }; 

回答

6

在C++ 11中,它被更改爲std::is_nothrow_default_constructible以更符合命名。

+0

+1 tyvm - 我將編輯代碼並嘗試一下 - 快放一邊,必須有一個'#ifdef'我可以用來檢查是否已經傳入了--std = C++ 11。 。...谷歌它 – kfmfe04

+0

@ kfmfe04你可以只使用'boost :: has_nothrow_default_constructor' – Pubby

+0

@ kfmfe04此外,'__cplusplus'是你可以檢查的宏,雖然它可能不能保證特質在那裏。 – Pubby

1

您正在查看GCC 4.6.2的文檔,但使用GCC 4.7.2,因此它們不匹配並不令人驚訝。

的性狀受n3142

改名爲見礦https://stackoverflow.com/a/12716778/981959的以前的答案爲一些代碼,試圖檢測由你的編譯器支持,但評論說,它不與工作的libC++。