- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
相关问题:Standard-layout and tail padding
片段:
#include <iostream>
#include <type_traits>
struct A0
{
int a;
char c;
};
struct B0 : A0
{ char d; };
struct A1
{
int a;
private:
char c;
};
struct B1 : A1
{ char d; };
struct A2
{
private:
int a;
char c;
};
struct B2 : A2
{ char d; };
int main()
{
std::cout << std::is_pod<A0>::value << ' ' << sizeof(B0) << std::endl; // 1 12
std::cout << std::is_pod<A1>::value << ' ' << sizeof(B1) << std::endl; // 0 8
std::cout << std::is_pod<A2>::value << ' ' << sizeof(B2) << std::endl; // 1 8
}
A2
是 POD,因为它的所有成员都有相同的访问控制,但是
B2
正在重用这样的尾部填充。这是为什么?
最佳答案
当前标准始终允许在任何基类子对象中重复使用对齐尾孔。它不必是“POD”(或现代的等价物,“可简单复制”)。实际上,任何基类子对象都是“可能重叠的子对象”,而“可能重叠的子对象”不是memcpy
-有能力的。
Itanium ABI 不跟踪当前标准中什么是或不是 POD 或等效项。它允许(实际上是强制)对齐尾孔在根据 C++98 定义不是 POD 的任何基础子对象中重用。
1.1 Definitions :
This ABI uses the definition of POD only to decide whether to allocate objects in the tail-padding of a base-class subobject. While the standards have broadened the definition of POD over time, they have also forbidden the programmer from directly reading or writing the underlying bytes of a base-class subobject with, say, memcpy. Therefore, even in the most conservative interpretation, implementations may freely allocate objects in the tail padding of any class which would not have been POD in C++98. This ABI is in compliance with that.
A2
不会是 POD,因为它有私有(private)成员。因此 GCC 根据 ABI 重用尾部填充,并符合当前标准或任何以前的 C++98 标准。
关于C++ + gcc : tail padding reuse and PODs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61548135/
我在 WebApi 项目中使用 DryIoc。默认重用设置为 Reuse.InWebRequest。在某些情况下,我需要在请求期间解析新实例。使用 Reuse.InCurrentScope 时,我可以
问题:当 Collection View 单元格滚动到屏幕外并重新使用时,对 Collection View 单元格的引用会发生什么情况?我在不使用“出队”的情况下提供细胞的所有尝试都失败了。有没有办
有什么想法可以解决如下所示的问题吗?根据我在网上找到的信息,它与重用 tensorflow 范围的问题有关,但没有任何效果。 ValueError: Variable rnn/basic_rnn_ce
去年,我参加了C++的数据结构类(class),因此以模板代码实现了所有主要的数据结构。我将所有内容都保存在闪存驱动器中,因为我觉得在生活中的某个时刻,我会再次使用它。我想我最终编程的东西将需要B树,
几年前,有人告诉我一项关于代码重用的研究。显然,发现程序员在搜索要重用的代码时平均有 7 分钟的时间。如果他们在那个窗口中没有找到适合他们需要的代码,他们就会编写自己的代码。 这是在需要仔细管理代码以
我一直是一个糟糕的程序员,因为我正在做复制和粘贴。一个例子是,每次我连接到数据库并检索记录集时,我都会复制以前的代码并编辑,复制设置 datagridview 的代码并进行编辑。我知道短语代码重用,但
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
关闭。这个问题需要多问focused 。目前不接受答案。 已关闭 3 年前。 已锁定。这个问题及其答案是locked因为这个问题是题外话,但却具有历史意义。目前不接受新的答案或互动。 任何代码都可以以
我通常会维护代码片段,我可以在 Wikidpad 个人 wiki 中重新使用这些代码片段,并带有一个小索引页面,可以将我带到我想要的任何代码。 我想与我的团队分享这些片段,并正在寻找简单的方法来做到这
我有以下路线,id 是一个可选参数,因此用户可以加载信息,或者如果没有提供 id,他们可以添加信息。我希望能够重用组件,这样页面就不必重新加载(在 ngOnInit 中调用 api),但是因为它们是两
我想对多个数据表应用相同的聚合,而不需要重写聚合方案。 考虑 dt1 <- data.table(id = c(1,2), a = rnorm(10), b = rnorm(10), c = rnor
我的公司有两到三个使用大量通用代码的 Web 应用程序——自定义 MVC 框架、实用程序类、JavaScript 库等等。 我们不想在每个应用程序中复制所有这些代码,因为我们最终会使用它的几个略有不同
许多个月前,我开始将我的音乐存储为 MP3。我疯狂地下载,然后将它们全部转储到一个文件夹中。在收集了数千首歌曲后,我一团糟。在我的空闲时间整理了所有音乐两年后,我已经把它放到了我图书馆的“D”部分。我
我正在尝试学习specflow,现在。 目前我有 2 个功能文件。 在第二个功能文件中,我重用了第一个功能文件中的一个步骤。 Specflow 自动识别第一个功能文件中的步骤,当 Specflow 为
有时我会偶然发现我想表达“请使用最后一个参数两次”的问题,例如为了编写无点样式或避免使用 lambda。例如。 sqr x = x * x 可以写成 sqr = doubleArgs (*) wher
这个问题已经有答案了: Javascript: how to pass found string.replace value to function? (3 个回答) 已关闭 7 年前。 我有一个功能
我想查找字符串中出现的字符(如果它们出现在某个“标记”字符之前或之后)。 所以我的标记是-,字符串是“a b-c d”。我想按顺序查找 b 和 c。 我试过了 re.findall(r'(-[a-z]
这个问题在这里已经有了答案: How to set variable reuse back to False in Tensorflow? (2 个答案) 关闭 6 年前。 有没有办法取消设置变量范
我会尽量简明扼要.. 我目前正在开发一个小型的实时“MMO”,并希望减少主机 -> 客户端的带宽使用。 其中成本最高的是字符串的使用,在大多数情况下,字符串会不断重复并发送给客户端。由于它们的性质(无
我读到 ThreadPoolExecutor 有线程池,这个池注定要降低创建新线程的成本(至少我是这样理解下面的短语): When you send a task to the executor, i
我是一名优秀的程序员,十分优秀!