C++ Logo

std-discussion

Advanced search

Re: Why structured bindings are not implicitly movable entities?

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sat, 09 Sep 2023 08:37:04 -0700
On Saturday, 9 September 2023 00:14:52 PDT Yexuan Xiao via Std-Discussion
wrote:
> I noticed the following words in [expr.prim.id.unqual]:
>
> * An implicitly movable entity is a variable of automatic storage
> duration that is either a non-volatile object or an rvalue reference to a
> non-volatile object type.
>
> This seems to exclude structured bindings.

That's because a structured binding is not a variable in the first place. It's
a binding to a larger variable. Automatically moving from a member of a larger
object that is not itself trivial could cause problems.

It's not the case in your example because std::vector::iterator and
std::string_view are trivially copyable and destructible.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-09-09 15:37:06