std is_assignable

1、实现分析

  /// is_assignable
  template<typename _Tp, typename _Up>
    struct is_assignable
      : public __bool_constant<__is_assignable(_Tp, _Up)>
    { };

2、关于 __is_assignable

通过修改日志确定 __is_assignable 是编译器gcc 内部实现逻辑,不是通过模版实现

Changes  [ 51c42b3] ⟷ [ 4543383])

> libstdc++: Optimize constructible/assignable variable templates
> 
> This defines the is_xxx_constructible_v and is_xxx_assignable_v variable
> templates by using the built-ins directly. The actual logic for each one
> is the same as the corresponding class template, but way using the
> variable template doesn't need to instantiate the class template.
> 
> This means that the variable templates won't use the static assertions
> checking for complete types, cv void or unbounded arrays, but that's OK
> because the built-ins check those anyway. We could probably remove the
> static assertions from the class templates, and maybe from all type
> traits that use a built-in.
> 
> libstdc++-v3/ChangeLog:
> 
> * include/std/type_traits (is_constructible_v)
> (is_default_constructible_v, is_copy_constructible_v)
> (is_move_constructible_v): Define using __is_constructible.
> (is_assignable_v, is_copy_assignable_v, is_move_assignable_v):
> Define using __is_assignable.
> (is_trivially_constructible_v)
> (is_trivially_default_constructible_v)
> (is_trivially_copy_constructible_v)
> (is_trivially_move_constructible_v): Define using
> __is_trivially_constructible.
> (is_trivially_assignable_v, is_trivially_copy_assignable_v)
> (is_trivially_move_assignable_v): Define using
> __is_trivially_assignable.
> (is_nothrow_constructible_v)
> (is_nothrow_default_constructible_v)
> (is_nothrow_copy_constructible_v)
> (is_nothrow_move_constructible_v): Define using
> __is_nothrow_constructible.
> (is_nothrow_assignable_v, is_nothrow_copy_assignable_v)
> (is_nothrow_move_assignable_v): Define using
> __is_nothrow_assignable.

* * *
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容