- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我认为当我删除 B
中的 move 构造函数时,下面的代码仍然可以正常编译,因为它仍然应该使用复制构造函数来构造 B
对象。为什么编译器现在会提示。没有 =delete
它就不会调用复制构造函数,因为它不允许提供默认的 move 构造函数!)
class B{
public:
B(){}
~B(){}
B & operator=(const B & b){
std::cout << " cannot move -> copy " << std::endl;
return *this;
}
B(const B & v){
std::cout << " cannot move -> copy " << std::endl;
}
// B(B && b) = delete; // uncomment this!
};
int main()
{
B b( B{} );
}
clang 3.6 的编译器输出 ( Live code )
main.cpp:27:7: error: call to deleted constructor of 'B'
B b( B{} );
^ ~~~
main.cpp:21:5: note: 'B' has been explicitly marked deleted here
B(B && b) = delete;
^
1 error generated.
最佳答案
定义被删除的函数仍然被声明。除其他事项外,它正常参与重载决议 - 但如果重载决议实际选择它,则程序格式错误([dcl.fct.def.delete]/2):
A program that refers to a deleted function implicitly or explicitly, other than to declare it, is ill-formed. [ Note: This includes calling the function implicitly or explicitly and forming a pointer or pointer-to-member to the function. It applies even for references in expressions that are not potentially-evaluated. If a function is overloaded, it is referenced only if the function is selected by overload resolution. —end note ]
这与从未声明过的函数不同。不存在的声明当然不参与重载决议。
关于c++ - 回退到复制构造函数不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29879834/
假设我这样做: SELECT * FROM table WHERE field2 = '2019@162440' OR field2 LIKE '%%2019@%%'; 在这种情况下,它会尝试同时执行
我正在研究背景大小有几个原因,但主要是因为通过使用它我可以使用 Sprite 和我可以使这些图像响应。当然,问题出在较旧的浏览器上,例如 IE8 及更低版本。 我希望我可以使用 polyfill但是这
我在单个 sprite 图像中包含页面上的许多图像,由于网站的其他要求,这些图像必须包含在单个 sprite 中。 虽然这在大多数浏览器中工作正常,但我在 Opera Mini 上遇到了一个问题,它根
我使用 CSS3 制作了一个圆圈,但在旧版浏览器(ie7 等)中出现了问题,圆圈显示为正方形。 我知道我可以使用背景图片作为备份,但这不是违背了使用代码的意义吗? 如果我要放入背景图像,它会放在 CS
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 8 年前。 Improve this qu
我在 iOS 应用程序中使用 stringsdict 功能进行本地化。该应用程序是英文的,正在本地化为法语。因此,我有一个英语版本作为基础,一个法语版本用于翻译。 如果作为用户,我将我的语言设置为其他
使用 .css() 进行回退的正确方法是什么?这最常用于字体后备,但我将它用于光标图像。 这是我得到的不起作用的东西: $("#dragable").css('cursor','url(images/
我正在使用 CDN 加载 Bootstrap.css。 我的问题是如何检查 CDN bootstrap 是否已加载/找到。 如果不是,则加载本地 Boostrap。 这是 Jquery 后备..
我是 NGINX 的新手,正在迁移服务器。我还没有完成新服务器上的所有内容,所以我希望它与新服务器匹配,除非该资源或路径不存在。如果是这样,我想将其发送到旧服务器。有没有办法做到这一点? 最佳答案 我
这是一个经典的后备解决方案。如果第一个 el 没有被渲染,那么它会使用其他渲染器重试。如何最好地重构它? 这段代码的问题在于: 渲染器需要位于数组中,但在这里,它们位于 then block 中。 当
我正在设置一个可变参数模板函数,以便能够在特定系列的类上调用各种函数重载。到目前为止,我已经能够在将不受支持的类传递给函数时“中断”编译,但我希望能够提供有效的回退以在运行时处理“不受支持”的情况。
我正在尝试在表单提交上创建一个 JSON 对象以传递给 Perl。我有几个嵌套的 div 和 ul 和 li 来允许 jQuery-ui 可排序。 为了能够保存排序后的 li(分布在多个 div 上)
ASP.NET 对于我使用的每个 appSetting,我想指定一个值,如果在 appSettings 中找不到指定的键,该值将被返回。我正要创建一个类来管理这个,但我认为这个功能可能已经在 .NET
我刚开始使用 ApacheKafka。我设置了整个事情,现在我试图在现有的 Java 应用程序中通过日志附加器引入 Kafka 发送日志。此应用程序使用 Logback 作为记录器库。所以,我猜,这让
回退 document.addEventListener('DOMContentLoaded',function(){/*code here*/}) 最佳答案 来自 MDN : Internet Ex
我一直在尝试编译一个 Android 应用程序,但我收到错误提示 java: non-static method canGoBack() cannot be referenced from a sta
我查看了无数答案并尝试了所有方法(似乎),但我仍然无法放松身心。 我有一个 Storyboard序列: 导航 Controller -> 主界面 Controller -> 导航 Controller
您知道是否有一种方法可以将媒体查询的完全相同的内容渲染到 LESS 中的类中? 为了解释我的情况:我先做移动,并试图避免被媒体查询覆盖。不幸的是,这最终排除了 ie8 及以下版本,因为大多数桌面样式都
有人建议我通过“@support”以下列方式组合 css-grid 和 css-table:支持网格的浏览器应该使用网格,不支持网格的浏览器回退到默认的表格样式。 现在看来,我的网格布局无法建立,即使
MathML是一种编写数学的网络标准,可以轻松缩放而无需像素化(就像 SVG)、复制和粘贴以及屏幕阅读器阅读。 Chrome 拒绝在存在 JavaScript polyfill 的基础上实现它。 (I
我是一名优秀的程序员,十分优秀!