c++类型特征概述

C++ Type Traits Overview

本文关键字:特征 类型 c++      更新时间:2023-10-16

有没有人把标准<type_traits> (GCC-4.6.1)和Boost自己的<boost/type_traits.hpp>中可用的所有类型特征的列表放在一起?

完整的特征列表可在网上获得:

  • Boost文档列出了<boost/type_traits.hpp>中的特征;
  • c++ 0x草案列出了<type_traits>中的特性。

然而,GCC的实现还没有完成。缺少GCC 4.6:

  • std::underlying_type性状。
  • std::is_trivially_X系列性状。相反,它有std::has_trivial_default_constructor和类似的名字似乎来自早期的草案。关于移动构造函数的那个缺失了。
  • std::is_nothrow_X系列性状。它们也使用较旧的名称,如std::has_nothrow_default_constructor。关于移动构造函数的那个也不见了。
  • std::aligned_union性状。这可以很容易地实现在std::aligned_storage方面,这是目前支持的。