auto

What is difference between decltype(auto) and decltype(returning expr) as return type?

柔情痞子 提交于 2019-12-04 00:16:20
What is the difference between decltype(auto) and decltype(returning expression) as return type of a function (template) if expr used without parentheses in both cases? auto f() -> decltype(auto) { return expr; } // 1 auto f() -> decltype(expr) { return expr; } // 2 Above f can be defined/declared in any context and can be either (member) function or (member) function template, or even (generic) lambda. expr can depend on any template parameters. In second version both expr are exactly the same expression without extra parentheses. Which differences can one expect, using first or second form

Why does C++ not allow multiple types in one auto statement?

大憨熊 提交于 2019-12-03 23:52:49
问题 The 2011 C++ standard introduced the new keyword auto , which can be used for defining variables instead of a type, i.e. auto p=make_pair(1,2.5); // pair<int,double> auto i=std::begin(c), end=std::end(c); // decltype(std::begin(c)) In the second line, i and end are of the same type, referred to as auto . The standard does not allow auto i=std::begin(container), e=std::end(container), x=*i; when x would be of different type. My question : why does the standard not allow this last line? It

initializer_list with auto contains multiple expressions

≯℡__Kan透↙ 提交于 2019-12-03 23:44:30
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 expressions auto x22 {1.0, 2.25, 3.5}; From Stroustroup's C++ book, page.162: auto x1 {1,2,3,4}; // x1 is

Error with using decltype() in C++11 (creating opaque error message in gcc 4.7.0)

眉间皱痕 提交于 2019-12-03 23:38:35
with the following code (a boiled-down version of my original code) #include <iostream> #include <cmath> template <typename> class A; // edit 1 following Mark & Matthieu template <typename X> class A { X a; template <typename> friend class A; // edit 1 following Mark & Matthieu public: A(X x) : a(x) {} X get() const { return a; } // edit 2 to avoid using A<Y>::a template <typename Y> auto diff(A<Y> const& y) const -> decltype(a - y.a) // original code causing error with gcc -> typename std::common_type<X, Y>::type // alternative following Rook -> decltype(this->get() - // edit 3 not using A<X>

Is it possible to have an “auto” member variable?

人走茶凉 提交于 2019-12-03 23:23:13
For example I wanted to have a variable of type auto because I'm not sure what type it will be. When I try to declare it in class/struct declaration it's giving me this error: Cannot deduce auto type. Initializer required Is there a way around it? struct Timer { auto start; }; You can, but you have to declare it static and const : struct Timer { static const auto start = 0; }; A working example in Coliru . With this limitation, you therefore cannot have start as a non-static member, and cannot have different values in different objects. If you want different types of start for different

Flex

自闭症网瘾萝莉.ら 提交于 2019-12-03 20:17:11
Flex 是 Flexible Box 的缩写,意为"弹性布局",用来为盒状模型提供最大的灵活性。 采用 Flex 布局的元素,称为 Flex 容器(flex container),简称"容器"。它的所有子元素自动成为容器成员,称为 Flex 项目(flex item),简称"项目"。 1. 父元素属性 1. display:flex; 一个容器设置了display:flex;属性就定义了一个flex容器,它的直接子元素会接受这个flex环境 2. flex-direction 决定主轴的方向(即项目的排列方向) .box { flex-direction: row | row-reverse | column | column-reverse; } 可以设置四个值: row: 默认值,水平从左到右 colunm: 垂直从上到下 row-reverse: 水平从右到左 column-reverse: 垂直从下到上 3. flex-wrap 默认情况下,项目都排在一条线(又称"轴线")上。flex-wrap属性定义,如果一条轴线排不下,如何换行。 .box{ flex-wrap: nowrap | wrap | wrap-reverse; } 可以设置三个值: nowrap: 默认值,不换行 wrap: 换行 wrap-reverse: 换行,且颠倒行顺序,第一行在下方 4.

Linux Oracle服务启动&停止脚本与开机自启动

旧街凉风 提交于 2019-12-03 19:41:37
一、在Linux下启动Oracle 登录到CentOS,切换到oracle用户权限 # su – oracle 接着输入: $ sqlplus "/as sysdba" 原本的画面会变为 SQL> 接着请输入 SQL> startup 就可以正常的启动数据库了。 另外停止数据库的指令如下: SQL> shutdown immediate 二、检查Oracle DB监听器是否正常 回到终端机模式,输入: $ lsnrctl status 检查看看监听器是否有启动 如果没有启动,可以输入: $ lsnrctl start 启动监听器 SQL> conn sys@orcl as sysdba 然后输入密码,sys以sysdba身份登入数据库。 三、启动emctl 另外也可以发现http://localhost.localdomain:1158/em 目前是没有反应的,这边要另外启动,启动的指令如下: $ emctl start dbconsole 这个指令运行时间较长,执行完的画面如下: 手动启动Oracle数据库完毕,下面创建系统自行启动Oracle的脚本。 四、Oracle启动&停止脚本 1. 修改Oracle系统配置文件:/etc/oratab,只有这样,Oracle 自带的dbstart和dbshut才能够发挥作用。 # vi /etc/oratab orcl:/opt

div样式在IE下margin:0 auto不居中多种解决方法

a 夏天 提交于 2019-12-03 14:26:32
正常情况下需要将div居中显示时,使用Css样式:margin:0 auto即可,但有时使用margin:0 auto后在FF、Chrome里能居中,而在IE678里不居中的现象。 正常情况下需要将div居中显示时,使用Css样式: margin:0 auto 即可,但有时使用margin:0 auto后在FF、Chrome里能居中,而在IE678里不居中的现象。 如下代码: XML/HTML Code 复制内容到剪贴板 < style type = "text/css" > #con{width:980px;martin:0 auto;} </ style > < div id = "con" > margin: 0 auto 内容居中显示 </ div > 解决方法一 可以是对网页主体<body>声明文本居中,即body{text-align:center} 即: XML/HTML Code 复制内容到剪贴板 < style type = "text/css" > body{text-align:center} #con{width:980px;martin:0 auto;} </ style > < div id = "con" > margin: 0 auto 内容居中显示 </ div > 解决方法二 其实和解决方法一差不多,只是在要居中的div外层添加多一个div

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

偶尔善良 提交于 2019-12-03 13:28:43
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? A a[2]; for(auto& x_:a){ auto* x = &x_; // code } You don't. If you want a pointer, either write a classical for-loop, or loop by reference and take the address. I'm not recommending it, but if you insist on using pointer -> syntax, just make an array of A* and

CSS3布局模式:伸缩布局盒(Flexbox)

夙愿已清 提交于 2019-12-03 12:53:27
介绍 Flexbox(伸缩布局盒) 是 CSS3 中一个新的布局模式,为了现代网络中更为复杂的网页需求而设计。本文将介绍 Flexbox 语法的技术细节。浏览器的支持越来越快,所以当 Flexbox 被广泛支持并应用时你将会快人一步。如果你想知道它是什么并是如何工作的,不妨仔细了解下吧! 为什么需要伸缩布局盒(Flexbox)? 作者长期以来使用表格、浮动、行内块元素和其他 CSS 属性来布局网站内容。然而,这些并不是为复杂的页面和网页应用而设计的。不管是简单的垂直居中,还是灵活的网格布局都很难靠一己之力轻易实现,因此成就了 CSS 网格框架 。但是,如果真的需要那么多项目来实现做这些事,为什么不让它来的更简单些呢?Flexbox 的目的就是改变这一切。 规范状态和浏览器支持情况 Flexbox 规范的相关工作已经进展了3年。不同的浏览器也实现了不同的实验版本。在2012年9月, Flexbox 语法的第三个主要修订版本进入到候选推荐阶段 。这意味着 W3C 认为当前的语法是稳定的,并鼓励浏览器开发商去实现它。 Flexbox 规范时间表: 2009年7月 工作草案 (display: box;) 2011年3月 工作草案 (display: flexbox;) 2011年11月 工作草案 (display: flexbox;) 2012年3月 工作草案 (display: