Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

An idea and a question

24 views
Skip to first unread message

Bonita Montero

unread,
Apr 17, 2023, 11:40:08 AM4/17/23
to
Does anyone know some library that does a move-construction or move
-assigment on a foreign type, i.e. not on its own type ? I'm wondering
if this makes sense sometimes.

Daniel

unread,
Apr 17, 2023, 12:19:14 PM4/17/23
to
std::optional<T> has a converting move constructor,

template < class U >
constexpr optional( optional<U>&& other );

with the requirements that T is not constructible from std::optional<U>,
and std::optional<U> is not convertible to T.

See https://en.cppreference.com/w/cpp/utility/optional/optional.

Daniel

Bonita Montero

unread,
Apr 17, 2023, 2:03:10 PM4/17/23
to
Cool, thanks.
I think an r-value reference also makes sense if the moved of forwared
object is later a part of the constructed object; but I never had such
code so far.

0 new messages