All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Examining Destructive Move Semantics in C++26: Can Programmers Express Object-Consuming Functions?

By

signa11

6mo ago· 2 min readenInsight

Summary

The article discusses whether C++26 will include destructive move semantics, which would allow functions to consume objects without running their destructors on moved-from objects. It examines the proposed library function trivially_relocate_at as an example and questions whether programmers can express similar functionality themselves. The author explores the technical challenges of conveying that a function effectively destructs an object at the source location or constructs one at the destination, suggesting the answer is likely no based on existing examples that avoid this through manual memory management.

Key quotes

· 5 pulled
Can I express a function that consumes an object? Meaning that its destructor is not run on the moved-from object?
Like the proposed library function trivially_relocate_at itself?
template <class T> T* trivially_relocate_at(T* dst, T* src);
That function signature does not convey that it effectively destructs an object at src, or the reverse problem, that it effectively constructs an object at dst.
I suspect the answer is no: The few examples I have found are avoiding it by doing manual memo
Snippet from the RSS feed

You might also wanna read