has :: std :: has_nothrow_default_constructor已被移动/更改?

时间:2012-12-17 06:40:31

标签: c++ boost c++11 std

在使用gcc 4.7.2尝试build boost mirror时,我遇到了这个错误,但奇怪的是,我看到了this documentation

移动/更改了::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

使用下面的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>
 { };

2 个答案:

答案 0 :(得分:6)

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

答案 1 :(得分:1)

您正在查看GCC 4.6.2的文档,但使用的是GCC 4.7.2,因此它们不匹配并不奇怪。

这些特征由n3142

重命名

有关尝试检测编译器支持哪些代码的代码,请参阅我的https://stackoverflow.com/a/12716778/981959的上一个答案,尽管注释说它不适用于libc ++。