auto

arrow operator (->) in function heading

会有一股神秘感。 提交于 2019-11-26 23:48:14
I found such code: template <typename T, typename T1> auto compose(T a, T1 b) -> decltype(a + b) { return a+b; } I figured with all details, that were new to me, but one. Tell me please, where can I read about, what does the arrow operator ( -> ) mean in function heading? I guess purely logically, that -> operator determines a type, that will be gotten by auto , but I want to get this straight, but can't find information. Jan Hudec In C++11, there are two syntaxes for function declaration: return-type identifier ( argument-declarations... ) and auto identifier ( argument-declarations... ) ->

stage3D 搭建2d图形引擎 (六) 显示列表

会有一股神秘感。 提交于 2019-11-26 22:49:26
显示列表的概念 Flash传统的显示列表实质上是一种树形数据结构,可以用下面的图来表示: 这一数据结构的实现是通过两个类:DisplayObject和DisplayObjectContainer,其中前者为后者的父类(介于阅读的方便,我省略了这两个类的一些几何属性和方法,更完整的内容可以参考后面的源码资源): DisplayObject: 1 package psw2d.display 2 { 3 import flash.geom.Matrix; 4 5 import psw2d.render.RenderMaster; 6 7 public class DisplayObject 8 { 9 private var _alpha:Number; 10 protected var _tined:Boolean; 11 private var _visible:Boolean; 12 private var _blendMode:String; 13 private var _transformationMatrix:Matrix; 14 private var _parent:DisplayObjectContainer; 15 private var _isOrientationChanged:Boolean;//显示对象的方位参数是否改变过 16 17 private var

Purpose of perfect forwarding for Callable argument in invocation expression?

巧了我就是萌 提交于 2019-11-26 22:04:15
问题 In Scott Meyer's book Effective Modern C++ on page 167 (of the print version), he gives the following example: auto timeFuncInvocation = [](auto&& func, auto&&... params) { // start timer; std::forward<decltype(func)>(func)( std::forward<decltype(params)>(params)... ); // stop timer and record elapsed time; }; I completely understand the perfect forwarding of params , but it is unclear to me when perfect forwarding of func would ever be relevant. In other words, what are the advantages of the

慎用auto关键词

杀马特。学长 韩版系。学妹 提交于 2019-11-26 21:45:14
C++11 标准推出了一个新的关键词 auto ,这个关键词可以通过表达式自动推断返回值的类型,这也是新标准中被各编译器厂商支持最为广泛的特性之一。利用这个关键词可以有效减少代码的长度,特别是在使用模板元编程的时候。 举个简单的例子: vector < map < int , string >> stringMapArray; // 不使用 auto 版本 vector < map < int , string >>:: iterator iter1 = stringMapArray. begin (); // 使用 auto 版本 auto iter2 = stringMapArray. begin (); 看到这样简短的式子,我再也不能忍受第一个包含大量冗余信息的式子了。所以,最近写的C++里到处都是auto,恨不得在lambda的参数列表里也用(可惜不行)。 但是物极必反,auto的滥用却使一个非常隐蔽的问题悄然出现。最近写一个正则引擎的时候,发现运行效率总是低于预期,刚开始认为是动态内存分配的问题,通过替换成内存池后发现虽然效率有所提高,但是仍然达不到要求。于是想到了性能工具,一次检查下来发现如下语句竟然占用了70%的时间: // 函数声明 set< int >& getSet(); void foo() { // 占用 70% 的时间 auto s = getSet ()

margin属性以及垂直外边距重叠问题

試著忘記壹切 提交于 2019-11-26 21:09:01
盒子的margin属性 盒子的外边距margin 指的是当前盒子与其他盒子之间的距离,环绕在盒子周围的空白区域,属于不可见的区域,,不会影响到可见框的大小,而是会影响到盒子的位置。 margin属性可以用来指定盒子外边框的大小,有两种方法设置外边距:第一种单独属性分别设置四个方向的外边距,第二种是使用简写属性同时设置多个方向的外边距(注意顺序),margin 属性接受任何长度单位,可以是像素px、英寸in、毫米mm或 em 一、 单独属性设置各个方向外边距 盒子有四个方向的外边距。 margin-top 上外边距,盒子的上边框与其他盒子的距离; margin-left 左外边距,盒子的左边框与其他盒子的距离; margin-right 右外边距,盒子的右边框与其他盒子的距离; margin-bottom 底外边距,盒子的底边框与其他盒子的距离。 示例代码 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>margin</title> 6 <style type="text/css"> 7 .box1{ 8 width: 200px; 9 height:200px; 10 background-color: #bfa; 11 border:1px solid red; 12

Is there a way to pass auto as an argument in C++?

对着背影说爱祢 提交于 2019-11-26 21:06:27
问题 Is there a way to pass auto as an argument to another function? int function(auto data) { //DOES something } 回答1: If you want that to mean that you can pass any type to the function, make it a template: template <typename T> int function(T data); There's a proposal for C++17 to allow the syntax you used (as C++14 already does for generic lambdas), but it's not standard yet. 回答2: Templates are the way you do this with normal functions: template <typename T> int function(T data) { //DOES

Oracle之自动收集统计信息

天大地大妈咪最大 提交于 2019-11-26 20:32:03
一、Oracle 11g 在Oracle的11g版本中提供了统计数据自动收集的功能。在部署安装11g Oracle软件过程中,其中有一个步骤便是提示是否启动这个功能(默认是启用这个功能)。 在这里介绍一下怎么将该功能启用与禁用: 1、查看自动收集统计信息的任务及状态: SQL > select client_name,status from dba_autotask_client; CLIENT_NAME STATUS -- -------------------------------------- ---------------- auto optimizer stats collection ENABLED auto space advisor ENABLED sql tuning advisor ENABLED 其中"auto optimizer stats collection"便是我们要寻找的自动收集统计信息的任务名称,它的状态目前是启用状态。 2、禁止自动收集统计信息的任务 禁用自动收集统计信息的任务可以使用DBMS_AUTO_TASK_ADMIN包完成: SQL > exec DBMS_AUTO_TASK_ADMIN.DISABLE(client_name => ' auto optimizer stats collection ' ,operation =>

BIOS中英文对照

懵懂的女人 提交于 2019-11-26 19:57:06
【推荐】BIOS中英文对照 BIOS中英文对照 Time/S***em Time 时间/系统时间 Date/S***em Date 日期/系统日期 Level 2 Cache 二级缓存 S***em Memory 系统内存 Video Controller 视频控制器 Panel Type 液晶屏型号 Audio Controller 音频控制器 Modem Controller 调制解调器(Modem) Primary Hard Drive 主硬盘 Modular Bay 模块托架 Service Tag 服务标签 Asset Tag 资产标签 BIOS Version BIOS版本 Boot Order/Boot Sequence 启动顺序(系统搜索操作系统文件的顺序) Diskette Drive 软盘驱动器 Internal HDD 内置硬盘驱动器 Floppy device 软驱设备 Hard-Disk Drive 硬盘驱动器 USB Storage Device USB存储设备 CD/DVD/CD-RW Drive 光驱 CD-ROM device 光驱 Modular Bay HDD 模块化硬盘驱动器 Cardbus NIC Cardbus总线网卡 Onboard NIC 板载网卡 Boot POST 进行开机自检时(POST)硬件检查的水平:设置为"MINIMAL"

Why does auto a=1; compile in C?

北慕城南 提交于 2019-11-26 19:03:16
问题 The code: int main(void) { auto a=1; return 0; } gets compiled without errors by the MS Visual Studio 2012 compiler, when the file has the .c extension. I have always thought that when you use the .c extension, compilation should be according to the C syntax, and not C++. Moreover, as far as I know auto without a type is allowed only in C++ since C++11, where it means that the type is deduced from the initializer. Does that mean that my compiler isn't sticking to C, or is the code actually

Range-for-loops and std::vector<bool>

无人久伴 提交于 2019-11-26 18:23:07
问题 Why does this code work std::vector<int> intVector(10); for(auto& i : intVector) std::cout << i; And this doesn't? std::vector<bool> boolVector(10); for(auto& i : boolVector) std::cout << i; In the latter case, I get an error error: invalid initialization of non-const reference of type ‘std::_Bit_reference&’ from an rvalue of type ‘std::_Bit_iterator::reference {aka std::_Bit_reference}’ for(auto& i : boolVector) 回答1: Because std::vector<bool> is not a container ! std::vector<T> 's iterators