
AMDG Mathias Gaunard wrote:
Giovanni Piero Deretta wrote:
I think that the biggest problem is that, if T is movable, you cannot statically guarantee that T is never accessed in an empty state, so the never empty guarantee is not as useful.
You can only move from rvalues. Rvalues cannot be accessed later on.
If they're not real rvalues, that means casting was used. Which should then make it explicit that trying to access it later on is undefined behaviour as far as the implementation of the type is concerned.
Such a move would be much too limiting. Consider how std::remove would be implemented (untested): template<class Iter, class T> Iter remove(Iter begin, Iter end, const T& value) { begin = std::find(begin, end, value); Iter write_pos = begin++; for(; begin != end; ++begin) { if(*begin != value) { *write_pos++ = std::move(*begin); } } return(write_pos); } In Christ, Steven Watanabe