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. 关于使用easyui 中提示dialog is not a function的问题

    我们经常在一些项目使用easyui,当然必不可少都会用到dialog这个功能,但是有时候你会发现: 明明我的代码没有错误,调用的规范按照API的来撰写,但是还有会报 $(...).dialog is ...

  2. System.DllNotFoundException: Unable to load DLL 'libgdiplus': The specified module could not be found.

    netcore 使用System.Drawing 出现如下错误: Unhandled Exception: System.TypeInitializationException: The type i ...

  3. 设计Optaplanner下实时规划服务的失败经历

    其实本文不知道算不算一个知识点分享,过程很美妙,但结果很失败.我们在利用Optaplanner的Real-Time planning(实时规则)功能,设计实时在线规划服务时,遇到一个属于Optapla ...

  4. lenovo 笔记本ideapad 320c-15改装win7问题

    lenovo 笔记本ideapad 320c-15改装win7问题: 去联想售后官网下载个Lenovo Utility驱动安装上,正常重启下,按Fn+F7,单击无线就能够开启无线网卡.Fn+F11.F ...

  5. LeetCode——17. Letter Combinations of a Phone Number

    一.题目链接: https://leetcode.com/problems/letter-combinations-of-a-phone-number/ 二.题目大意: 给定一段数字字符串,其中每个数 ...

  6. elasticSearch 2.3 delete-by-query plugin

    The delete-by-query plugin adds support for deleteing all of the documents which match the specified ...

  7. xamarin android 开发

    开始环境vs2017 直接创建android 项目,左边是android studio 的项目目录  右边是vs创建的android 项目目录 结构基本相同,有res对应的Resources文件 加载 ...

  8. 基于Python的设计模式简述

    结构梳理>>> 第一部分: 创建型模式 工厂模式 工厂方法 抽象工厂 建造者模式 原型模式 单例模式 第二部分: 结构型模式 适配器模式 修饰器模式 外观模式 享元模式 模型-视图- ...

  9. 用自己的话简要阐述struts2的执行流程

    Struts 2框架本身大致可以分为3个部分:核心控制器FilterDispatcher.业务控制器Action和用户实现的企业业务逻辑组件.核心控制器FilterDispatcher是Struts ...

  10. 215.Spring Boot+Spring Security:初体验

    [视频&交流平台] SpringBoot视频:http://t.cn/R3QepWG Spring Cloud视频:http://t.cn/R3QeRZc SpringBoot Shiro视频 ...