A compiler vendor would typically implement a reference as a pointer. Pointers tend to be the same size as or larger than many of the built-in types. For these built-in types the same amount of data would be passed whether you passed by value or by reference. In the function, in order to get the actual data, you would however need to dereference this internal pointer. This can add an instruction to the generated code, and you will also have two memory locations that may not be in cache. The difference won't be much - but it could be measured in tight loops.

A compiler vendor could choose to disregard const references (and sometimes also non-const references) when they're used on built-in types - all depending on the information available to the compiler when it deals with the function and its callers.

C++: Why pass-by-value is generally more efficient than pass-by-reference for built-in (i.e., C-like) types的更多相关文章

  1. 网易云课堂_C语言程序设计进阶_第三周:结构:结构、类型定义、联合

    3.1 枚举 3.2 结构 3.3 类型定义 3.1 枚举 枚举是一种用户定义的数据类型,它用关键字enum以如下语法来表明: enum 枚举类型名字{名字0,...,名字n}; 枚举类型名字通常并不 ...

  2. 听翁恺老师mooc笔记(11)--结构和函数

    结构作为函数参数: 声明了一个结构就有了一种自定义的数据类型,这个数据类型和int.float.double一样,int等基本类型可以作为函数的参数,那么这种个自定义的结构类型也应该可以作为函数参数, ...

  3. [模拟电路] 2、Passive Band Pass Filter

    note: Some articles are very good in http://www.electronics-tutorials.ws/,I share them in the Cnblog ...

  4. AI基础架构Pass Infrastructure

    AI基础架构Pass Infrastructure Operation Pass OperationPass : Op-Specific OperationPass : Op-Agnostic Dep ...

  5. What's Assembly - CSharp - Editor - first pass.dll? Best How to Fix Assembly - CSharp - Editor - first pass.dll Error Guide

    If you've found yourself here, I'm guessing that you're getting Assembly - CSharp - Editor - first p ...

  6. Python pass 语句使用示例

    Python pass 语句的使用方法示例.Python pass是空语句,pass语句什么也不做,一般作为占位符或者创建占位程序,是为了保持程序结构的完整性,pass语句不会执行任何操作,比如: P ...

  7. 采用ftpServer构建嵌入式ftp服务器时设置pass功能

    讲ftpserver嵌入式ftp服务器的文章很多,但是都没有介绍pass功能设置的. apach上pass部分也是针对的ftpd服务器的xml配置,关于嵌入式ftp服务器设置pass功能的部分几乎没有 ...

  8. pass

    空语句 do nothing 保证格式完整 保证语义完整 以if语句为例,在c或c++/java中: if(true) ; //do nothing else { //do something } 1 ...

  9. Sallen-Key Active Butterworth Low Pass Filter Calculator

    RC 2nd Order Passive Low Pass Filter The cut-off frequency of second order low pass filter is given ...

随机推荐

  1. [Hive - LanguageManual] GroupBy

    Group By Syntax Simple Examples Select statement and group by clause Advanced Features Multi-Group-B ...

  2. openstack分布式安装

    一. keystone安装笔记 初次接触openstack,在尝试过单机部署以后不是很满意,就开始着手分布式部署,主要是按照openstack官网上的安装教程来的,本人安装的是目前最新的 I 版. 以 ...

  3. Codeforces 381 简要题解

    做的太糟糕了...第一题看成两人都取最优策略,写了个n^2的dp,还好pre-test良心(感觉TC和CF的pretest还是很靠谱的),让我反复过不去,仔细看题原来是取两边最大的啊!!!前30分钟就 ...

  4. Codeforces 375

    A 7的所有的余数都可以用1,6,8,9排列得到,然后搞一下就可以了. B 可以用类似于单调队列的东西搞.具体看代码: /* * Problem: B. Maximum Submatrix 2 * A ...

  5. Java多线程编程之同步器

    同步器 为每种特定的同步问题提供了解决方案 Semaphore Semaphore[信号标:旗语],通过计数器控制对共享资源的访问. 测试类: package concurrent; import c ...

  6. 第二百四十二天 how can I 坚持

    今天... 貌似没啥啊. 第一天带帽子上班. 还有回来买了两个柚子吃了,有点上火啊. 还有今天雾霾爆表啊,pm2.5  600多啊. 还有看了部电影<蚁人>,挺好看.希望不会出二.三.四. ...

  7. CoffeeScript学习(3)—— 函数

    CoffeeScript函数 如果大家有看我之前关于ES6的箭头函数的话,这一篇也不会很难理解.我们这一次可以说一下,关于两者的一些细微差别. 基本 在CoffeeScript中,任何函数都是用箭头函 ...

  8. Hibernate3注解

    1.@Entity(name="EntityName") 必须,name为可选,对应数据库中一的个表 2.@Table(name="",catalog=&quo ...

  9. BestCoder Round #69 (div.2)(hdu5611)

    Baby Ming and phone number Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Ja ...

  10. 创建类模式(二):抽象工厂(Abstract Factory)

    定义 为创建一组相关或相互依赖的对象提供一个接口,而且无需指定他们的具体类. 抽象工厂模式是所有形态的工厂模式中最为抽象和最具一般性的一种形态.抽象工厂模式是指当有多个抽象角色时,使用的一种工厂模式. ...