Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
在 C 中获取临时(复合文字)参数的地址
I can t imagine this isn t already duplicate but I can t easily find the answer since the more complex scenarios specifi
c
languagelawyer
C99
initializer
temporaryobjects
临时函数参数的生命周期是多长? [复制]
这个问题在这里已经有答案了 当创建一个新实例时MyClass作为函数的参数 如下所示 class MyClass MyClass int a myFunction MyClass 42 该标准是否对析构函数的时间做出任何保证 具体来说 我可
c
destructor
lifetime
temporaryobjects
从方法链中使用的临时移出
我正在尝试做类似的事情 include
c
move
methodchaining
temporaryobjects
Rust 中涉及临时对象的销毁顺序
在 C 中 如果错误 请纠正我 通过常量引用进行的临时绑定应该比它所绑定的表达式寿命更长 我认为 Rust 也是如此 但在两种不同的情况下我得到了两种不同的行为 考虑 struct A impl Drop for A fn drop mut
Rust
temporaryobjects
以下示例中给出的结构有何不幸之处?
15 6 2 初始化基数和成员 N4713 节在第 11 项之后有以下示例 struct A A default OK A int v v v OK const int v 42 OK A a1 error ill formed bindi
c
constructor
reference
temporaryobjects
sqlite:只读数据库中的临时表/视图?
看来 sqlite 不允许我在只读数据库中创建临时视图 我错过了什么吗 如果它是临时的 我认为数据库连接模式应该不重要 我什至指定了 PRAGMA temp store MEMORY 它没有帮助 除了使用视图之外 还有其他合理的选择吗 您可
SQLite
temporaryobjects
是否有任何 C++ 编译器可以针对悬空引用发出警告?
给出以下代码 其中x是一个悬空的const reference到一个消失的对象 因此是未定义的行为 auto get vec return std vector
c
compilerwarnings
temporaryobjects
constreference
在临时对象上调用成员函数时生成警告
给定一个矩阵模板类mat
c
C17
temporaryobjects
聚合初始化中 mem-initializer 的有效性和/或生命周期扩展
CWG 1815asked http www open std org jtc1 sc22 wg21 docs cwg defects html 1815 有少量修改 struct A struct B A a A B b1 1 B b2
c
c14
languagelawyer
lifetime
temporaryobjects
const 引用是否会延长临时对象返回的临时对象的寿命?
我知道常量引用可以延长本地临时变量的寿命 现在我问自己是否可以将这种专有性扩展到临时对象链上 也就是说 我是否可以安全地定义 std string const foo aBar getTemporaryObject1 getTemporar
c
lifetime
rvalue
temporaryobjects
referencebinding
为什么不对临时对象进行非常量引用? [复制]
这个问题在这里已经有答案了 C 只允许将临时对象分配给 const 引用 它不允许分配临时对象来引用 例如 String a String test Error const String a String test Ok 我到处谷歌搜索这个
c
reference
lifetime
temporaryobjects
在 C++ 11 中将指针传递给临时对象?
我有一个现有的功能 void foo const Key key nullptr uses the key 我想将其指针传递给临时 Key 对象 即右值 例如 foo Key 这会导致编译错误 但是在 c 11 14 中有没有办法可以做到这
c
C11
c14
C17
temporaryobjects
禁止实例化为临时对象 (C++)
我喜欢在 C 中使用哨兵类 但我似乎有一种精神困扰 导致反复编写如下错误 MySentryClass arg other code 不用说 这会失败 因为哨兵在创建后立即死亡 而不是按预期在作用域结束时死亡 有没有某种方法可以防止 MySe
c
temporary
temporaryobjects
如何以自然的语法实现线程安全容器?
Preface 如果按原样使用 下面的代码会导致未定义的行为 vector
c
templates
threadsafety
c14
temporaryobjects
临时对象存储在哪里?
是不是真的临时对象存储在动态 堆 内存中 标准没有为它们强制任何内存区域 堆 堆栈 但它们就像局部变量 自动存储 一样 位于表达式的末尾 或者当绑定到引用常量时更长 被破坏 大多数实现会将它们像局部变量一样存储在堆栈中 edit 正如 Ja
c
heapmemory
temporaryobjects
stackmemory
返回临时 const 引用的行为与本地 const 引用不同?
我试图更好地理解如何将左值和右值作为引用处理 因此我创建了这个玩具示例 include
c
reference
lifetime
temporary
temporaryobjects
使用 const 引用延长临时对象的寿命
我需要一些关于 const 引用的澄清 从这个链接 const Foo myFoo FuncBar const 引用延长了本地对象的寿命 但当我检查时这个链接尽管他们使用了 const 引用 Sandbox const string n m
c
passbyreference
lifetime
temporaryobjects
referencebinding
在发生异常时将临时对象绑定到非常量引用
我一直读到 在函数调用的情况下 临时变量只能与非常量引用参数绑定 CASE 1 例如 class Simple public int i Simple Simple f i f i 1 Simple int j i j int main S
c
temporaryobjects
为什么将引用绑定到右值是合法的?
据我了解 从函数返回右值引用是危险的原因是由于以下代码 T f T x do something to T x return static cast
c
C11
languagelawyer
rvaluereference
temporaryobjects
在临时字符串上使用 string::c_str [重复]
这个问题在这里已经有答案了 关于临时对象何时被销毁 这是否有效 FILE f fopen std string my path c str r 在评估第一个参数后 临时对象是否会立即被销毁fopen或之后fopen call 使用以下代码进
c
destructor
temporaryobjects
1
2
»