Skip to content

The confusing way moves are broken #402

Description

@lefticus
structS {
~S() {}
};

The above type does not have a move constructor or move assignment, but it still works with move operations and is_move_constructible returns true.

So how do we show that move operations don't exist?

https://compiler-explorer.com/z/dva81543s

#include<utility>
#include<type_traits>structContained {
Contained();
Contained(const Contained &);
Contained(Contained &&);
Contained &operator=(const Contained &);
Contained &operator=(Contained &&);
~Contained();
};
structS {
Contained c;
// comment this out and see the difference~S();
};
S getS();
static_assert(std::is_move_constructible_v<S>);
static_assert(std::is_move_assignable_v<S>);
voiduseS(S);
intmain()
{
S obj;
obj = getS();
useS(std::move(obj));
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions