3 ms·
Maybe I'm missing something, but why is it crucial that you hold on to a reference to the contents of the vector, and not the vector itself? Because, to me, the
by jeorgun 11y ago
Maybe I'm missing something, but why is it crucial that you hold on to a reference to the contents of the vector, and not the vector itself? Because, to me, the obvious "C++ way" to do it would be something like
struct FieldInfo {
//
const std::vector<ast::Attribute>& attrs;
}
- pcwalton 11y agoWell, if the object that owns the vector is destroyed then that reference will go dangling. The compiler can't (soundly) check this.
- lastontheboat 11y agoThat operates under the assumption that no FieldInfo will be accessible after the original vector is deallocated, and similarly requires auditing to ensure this property holds (while making no guarantees about the future).