std::remove_reference

  用于移除类型的引用,返回原始类型。

1、可能的实现。

  

2、例子.

#include <iostream> // std::cout
#include <type_traits> // std::is_same template<class T1, class T2>
void print_is_same() {
std::cout << std::is_same<T1, T2>() << '\n';
} int main() {
std::cout << std::boolalpha; print_is_same<int, int>();
print_is_same<int, int &>();
print_is_same<int, int &&>(); print_is_same<int, std::remove_reference<int>::type>();
print_is_same<int, std::remove_reference<int &>::type>();
print_is_same<int, std::remove_reference<int &&>::type>();
}

  输出 :

true
false
false
true
true
true

参考:

1、https://zh.cppreference.com/w/cpp/types/remove_reference

std::remove_reference的更多相关文章

  1. c++11::std::remove_reference

    引用移除 : remove_reference 引用折叠规则 A& & 折叠成 A&  A& && 折叠成 A&  A&& &a ...

  2. C++11 std::move和std::forward

    下文先从C++11引入的几个规则,如引用折叠.右值引用的特殊类型推断规则.static_cast的扩展功能说起,然后通过例子解析std::move和std::forward的推导解析过程,说明std: ...

  3. C++笔记--std::相关

    std::packaged_task https://www.cnblogs.com/haippy/p/3279565.html https://en.cppreference.com/w/cpp/t ...

  4. item 23: 理解std::move和std::forward

    本文翻译自<effective modern C++>,由于水平有限,故无法保证翻译完全正确,欢迎指出错误.谢谢! 博客已经迁移到这里啦 根据std::move和std::forward不 ...

  5. std::move 移动对象资源

    场景: C++ 标准库使用比如vector::push_back 等这类函数时,会对参数的对象进行复制,连数据也会复制.这就会造成对象内存的额外创建, 本来原意是想把参数push_back进去就行了. ...

  6. 关于C++11中的std::move和std::forward

    std::move是一个用于提示优化的函数,过去的c++98中,由于无法将作为右值的临时变量从左值当中区别出来,所以程序运行时有大量临时变量白白的创建后又立刻销毁,其中又尤其是返回字符串std::st ...

  7. std::bind技术内幕

    引子 最近群里比较热闹,大家都在山寨c++11的std::bind,三位童孩分别实现了自己的bind,代码分别在这里: 木头云的实现 mr.li的实现 null的实现,null的另一个版本的实现 这些 ...

  8. 山寨一个std::bind\boost::bind

    这里是最初始的版本,参考https://github.com/cplusplus-study/fork_stl/blob/master/include/bind.hpp 提供了最简洁的实现方式. 第一 ...

  9. C++0x,std::move和std::forward解析

    1.std::move 1.1std::move是如何定义的 template<typename _Tp> constexpr typename std::remove_reference ...

随机推荐

  1. excel怎么把单元格内某个字标红,其他字不变

    alt+F11,打开宏编辑器运行如下代码: Sub AAA() Dim R As Range, L As Long, S As String Application.ScreenUpdating = ...

  2. PLSQL脚本中自定义异常的简单使用

    第一步:自定义异常 excp_notexists exception 第二步:捕获异常 begin                select *** into *** from *** where ...

  3. Ubuntu 15.10 下Redis Cluster使用

    1 Redis Standalone安装 可以参考这篇博文:http://www.cnblogs.com/_popc/p/3684835.html 2 Redis Cluster安装 2.1 环境介绍 ...

  4. 通过c++11的condition_variable实现的有最大缓存限制的队列

    之前曾写过一个通过C++11的condition_variable实现的有最大缓存限制的队列,底层使用std::queue来实现,如果想要提升性能的话,可以考虑改用固定的长度环形数组.环形数组实现如下 ...

  5. win10 mac随机功能测试

    win10 MAC随机功能指针对无线网卡 随机功能包含网卡随机, 跟网络随机两种, 这两种互不影响 一“无线网卡mac随机” 单击无线图标->网络和internet设置->wlan 影响无 ...

  6. Redis单线程架构

    参考链接: http://blog.csdn.net/qqqqq1993qqqqq/article/details/77538202 单线程模型: redis中的数据结构并不全是简单的kv,还有lis ...

  7. 搭建Hadoop

    最近开始学习hadoop现实是完全分布式 安利大佬博客学习 https://blog.csdn.net/downing114/article/details/60956979 在Ubuntu上学习  ...

  8. 【BZOJ2054】疯狂的馒头(并查集)

    /* 经典思路, 倒序并查集处理即可 */ #include<cstdio> #include<algorithm> #include<cstring> #incl ...

  9. Python爬虫的步骤和工具

    #四个步骤 1.查看crawl内容的源码格式          crawl的内容可以是 url(链接),文字,图片,视频 2.请求网页源码 (可能要设置)代理,限速,cookie 3.匹配 用正则表达 ...

  10. Struts2高位漏洞升级到struts2.3.32

    Struts2高位漏洞升级到struts2.3.32 3月7日带来了一个高危漏洞Struts2漏洞——CVE编号CVE-2017-5638.其原因是由于Apache Struts2的Jakarta M ...