Lightning Talk: Ref, C++ const ref, immutable ref? - Francesco Zoffoli - CppCon 2022

preview_player
Показать описание
---

Lightning Talk: Ref, C++ const ref, immutable ref? - Francesco Zoffoli - CppCon 2022

In c++ a const reference is a read only view on potentially changing data. What would it take to create a reference to data that is Immutable? And what would be the advantages?
---

Francesco Zoffoli
__

#cppcon #programming #cpp
Рекомендации по теме
Комментарии
Автор

What's the purpose of the Immutable<T>, it still needs compare two times.

sunyi-ming
Автор

Sorry for asking a noob question, how does foo5 using Immutable ref solve the problem? Isn't in the assembly code there are still two if-checks?

ianwong
Автор

Either I didn't get the idea, or on the 11-th slide, the second access to the `i` is still reading its value, as if `f()` could still change it - just like in the first example. I.e.: `Immutable<int>&` - still doesn't work.

JustYouw
Автор

Can anyone clarify the problem with const ref? I didn't understand it..😮

alexeysubbota
Автор

Sounds like a perfect use case for a language where the compiler statically guarantees the mutability and exclusivity of your reference… perhaps like Rust.

neilweidinger