auto

initializer_list with auto contains multiple expressions

谁都会走 提交于 2019-12-05 09:26:41
问题 Rather simple question, auto x11 {1,2,3,4}; auto x1 = {1,2,3,4}; auto x22 {1.0, 2.25, 3.5}; auto x2 = {1.0, 2.25, 3.5}; As far as I understand, there should be no difference here with respect to having = or not. However, using llvm/clang 6.0.0 (with --std=c++17), I get : main1.cpp:35:17: error: initializer for variable 'x11' with type 'auto' contains multiple expressions auto x11 {1,2,3,4}; ~~~~~~~~ ^ main1.cpp:37:20: error: initializer for variable 'x22' with type 'auto' contains multiple

Is it valid to do explicit template specialisation with auto return 'type' in C++14?

久未见 提交于 2019-12-05 09:06:22
Previous question . I repeat the code from the previous question to make this question self-contained. The code below compiles and does not issue any warnings if it is compiled using gcc 4.8.3. with -std=c++1y . However, it does issue warnings if compiled with -std=c++0x flag. In the context of the previous question it was stated that the code does not compile using gcc 4.9.0. Unfortunately, at present, I do not fully understand how auto is implemented. Thus, I would appreciate if anyone could answer the following questions: 1). Is the code below valid C++ with respect to the C++14 standard? 2

mysql AUTO INCREMENT字段 语法

为君一笑 提交于 2019-12-05 04:22:05
mysql AUTO INCREMENT字段 语法 作用: 在新记录插入表中时生成一个唯一的数字 说明: 我们通常希望在每次插入新记录时,自动地创建主键字段的值。我们可以在表中创建一个 auto-increment 字段。 直线电机的分类及特点 mysql AUTO INCREMENT字段 示例 //把 "Persons" 表中的 "P_Id" 列定义为 auto-increment 主键 CREATE TABLE Persons(P_Id int NOT NULL AUTO_INCREMENT,LastName varchar(255) NOT NULL,FirstName varchar(255),Address varchar(255),City varchar(255),PRIMARY KEY (P_Id)); 来源: https://www.cnblogs.com/furuihua/p/11905432.html

Auto with uniform initialization expands to unexpected type

强颜欢笑 提交于 2019-12-05 03:32:05
问题 Consider this short program compiled with GCC 4.7.2 g++ -std=c++11 test.cc #include <memory> #include <queue> struct type{ type(int a) : v(a) {} int v; }; typedef std::shared_ptr<type> type_ptr; int main(){ int value = 3; std::queue<type_ptr> queue; auto ptr{std::make_shared<type>(value)}; queue.push(ptr); } The compiler outputs the following errors: src/test.cc: In function ‘int main()’: src/test.cc:15:17: error: no matching function for call to ‘std::queue<std::shared_ptr<type> >::push(std:

What is the type of “auto var = {condition} ? 1 : 1.0” in C++11? Is it double or int?

核能气质少年 提交于 2019-12-05 03:23:31
In C++11 what are the types of x and y when I write this? int main() { auto x = true ? 1 : 1.0; auto y = false ? 1 : 1.0; std::cout << x << endl; std::cout << y << endl; return 0; } The type is going to be double , because it's the common type of the literals 1 and 1.0 . There's a simple way to test that using typeid : #include <iostream> #include <typeinfo> using namespace std; int main() { auto x = true ? 1 : 1.0; cout << typeid(x).name() << endl; return 0; } This outputs d on my version of GCC. Running echo d | c++filt -t then tells us that d corresponds to the type double , as expected.

实现多层DIV叠加的js事件穿透

岁酱吖の 提交于 2019-12-05 02:36:28
Flash里面有个很好的特性是,一个容器里,不存在实际对象的部分,不会阻拦鼠标事件穿透到下一层。 前端就不一样了,两个div层叠以后,上层div会接收到所有事件(即使这个div里面内容是空的,没有任何实际对象),下层div什么事件都接不到。 举个例子: 这个示意图中 C方块在A容器中(A容器边框为红色) D方块在B容器中(B容器边框为绿色) A B部分重叠,B在上层。 不做任何处理的话,C方块永远无法被点到,因为B把它盖住了。 下面,我将给出一种方案,在不改变页面结构的情况下,让CD都能得到正常相应。 主要利用的是css中的 pointer-events 属性 语法: pointer-events :auto | none | visiblepainted | visiblefill | visiblestroke | visible | painted | fill | stroke | all 默认值 :auto 适用于 :所有元素 继承性 :有 动画性 :否 计算值 :指定值 取值: auto: 与pointer-events属性未指定时的表现效果相同。在svg内容上与 visiblepainted 值相同 none: 元素永远不会成为鼠标事件的target。但是,当其后代元素的pointer-events属性指定其他值时,鼠标事件可以指向后代元素,在这种情况下

How much is too much with C++11 auto keyword?

夙愿已清 提交于 2019-12-05 00:59:35
I've been using the new auto keyword available in the C++11 standard for complicated templated types which is what I believe it was designed for. But I'm also using it for things like: auto foo = std::make_shared<Foo>(); And more skeptically for: auto foo = bla(); // where bla() return a shared_ptr<Foo> I haven't seen much discussion on this topic. It seems that auto could be overused, since a type is often a form of documentation and sanity checks. Where do you draw the line in using auto and what are the recommended use cases for this new feature? To clarify: I'm not asking for a

NFS服务器搭建与autofs自动挂载

此生再无相见时 提交于 2019-12-05 00:40:11
NFS服务器搭建与autofs自动挂载 NFS服务器搭建与autofs自动挂载 一、 NFS是什么: NFS(Network File System)即网络文件系统,是FreeBSD支持的文件系统中的一种,它允许网络中的计算机之间共享资源。在NFS的应用中,本地NFS的客户端应用可以透明地读写位于远端NFS服务器上的文件,就像访问本地文件一样。 Autofs是什么: mount是用来挂载文件系统的,可以在系统启动的时候挂载也可以在系统启动后挂载。对于本地固定设备,如硬盘可以使用mount挂载;而光盘、软盘、NFS、SMB等文件系统具有动态性,即需要的时候才有必要挂载。光驱和软盘我们一般知道什么时候需要挂载,但NFS和SMB共享等就不一定知道了,即我们一般不能及时知道NFS共享和SMB什么时候可以挂载。而autofs服务就提供这种功能,好像windows中的光驱自动打开功能,能够及时挂载动态加载的文件系统。免去我们手动挂载的麻烦。要实现光驱,软盘等的动态自动挂载,需要进行相关的配置。 二.NFS文件详解 1. /data/ 表示需要共享的目录 2. IP 表示允许哪个客户端访问。 3. IP 后括号里的设置表示对该共享文件的权限。 4. ro 只读访问 5. rw 读写访问 6. sync 所有数据在请求时写入共享 7. all_squash

C Primer Plus 第12章 12.2 存储类说明符

可紊 提交于 2019-12-04 23:41:18
C语言中有5个关于存储类说明符的关键字,它们是auto、register、static、extern以及typedef。关键字typedef与内存存储无关,由于语法原因被归入此类。特别地,不可以在一个声明中使用一个以上存储类说明符,这意味着不能将其他任一存储类说明符作为typedef的一部分。 说明符auto表明一个变量具有自动存储时期。该说明符只能用在具有代码块作用域的变量声明中,而这样的变量已经拥有自动存储时期,因此它主要用来明确指出意图,使程序更易读。 说明符register也只能用于具有代码块作用域的变量。它将一个变量归入寄存器存储类,这相当于请求将该 变量存储在一个寄存器内,以更快地存取。它的使用也使您不能获得变量的地址。 说明符static在用于具有代码块作用域的变量的声明时,使该变量具有静态存储时期,从而得以在程序运行期间(即使在包含该变量的代码块并没有运行时)存在并保留其值。变量仍具有代码块作用域和空链接。static在用于具有文件作用域的变量的声明时,表明该变量具有内部链接。 说明符extern表明您在声明一个已经在别处定义了的变量。如果包含extern的声明具有文件作用域,所指向的变量必然具有外部链接。如果包含extern的声明具有代码块作用域,所指向的变量可能具有外部链接也可能具有内部链接,这取决于该变量的定义声明。 下面给出了一个使用全部5种存储类的小程序

C++11 range based auto for loop by value, reference, and pointer

北慕城南 提交于 2019-12-04 23:01:50
问题 I know how to use auto keyword in for loop to iterate this array either by value or reference. struct A { void fun() {}; }; int main() { A a[2]; // Value for (auto x : a) { x.fun(); } // Ref for (auto& x : a) { x.fun(); } // Pointer //for (...) { x->fun(); } } So I am looking third version of this convention. How do I use pointer here? 回答1: A a[2]; for(auto& x_:a){ auto* x = &x_; // code } 回答2: You don't. If you want a pointer, either write a classical for-loop, or loop by reference and take