Boost-源码分析笔记7-decay

喜欢这篇文章吗?喜欢的话去看博主的置顶博客,即可依据分类找到此文章的原版得到更好的体验,

图片及代码显示的问题,笔者深感抱歉,想要更好的体验去原博文即可。


title: Boost 源码分析笔记7 - decay
mathjax: true
date: 2020-03-17 16:41:19
categories: [c++笔记,Boost源码分析笔记]
tags: [c++笔记,Boost源码分析笔记]
keywords: [c++笔记,Boost源码分析笔记]


这篇博客要求提前知道

{% post_link ‘Boost-源码分析笔记2-is-array’ is_array %}
{% post_link ‘Boost-源码分析笔记4-is-function’ is_function%}
{% post_link ‘Boost-源码分析笔记5-remove-bounds’ remove_bounds%}
{% post_link ‘Boost-源码分析笔记6-remove-reference’ remove_reference%}
{% post_link ‘Boost-源码分析笔记1-remove-cv’ remove_cv%}

decay

   这个模版元的意思是移除引用、移除const、移除volatile、数组移除范围、函数变成指针。

   namespace detail
   {

      template <class T, bool Array, bool Function> struct decay_imp { typedef typename remove_cv<T>::type type; };
      template <class T> struct decay_imp<T, true, false> { typedef typename remove_bounds<T>::type* type; };
      template <class T> struct decay_imp<T, false, true> { typedef T* type; };

   }

    template< class T >
    struct decay
    {
    private:
        typedef typename remove_reference<T>::type Ty;
    public:
       typedef typename boost::detail::decay_imp<Ty, boost::is_array<Ty>::value, boost::is_function<Ty>::value>::type type;
    };

   实际上做起来的时候是先移除引用,最后移除cv的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值