28 May
2017
28 May
'17
11:27 p.m.
- T& .value() returns a reference to the value, non-destructive. - T .get() returns the value by value, destructive.
I have a class with similar behavior, I named the function which returns the value destructively T::release() to make it clear at call sites.
Example:
template<class T> class Holder { T t_; public: T release() { return std::move(t_); } };
Meh, .release() makes me think of smart pointers. Though afio::file_handle does have a .release() to detach the native handle. I'll ponder it. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/