Skip to content

X4Movable (all overloads of x4::move_to(src, dst)) should be SFINAE-friendly #45

@saki7

Description

@saki7

Some classes use X4Movable to show human-friendly errors but in return the current implementation of X4Movable is not SFINAE-friendly in certain scenario.

Generically speaking, any concept should be SFINAE-friendly. We should fix X4Movable while keeping human-friendly errors in all usages.

The overload below should ideally be = delete("with reason"); but it's not implemented in C++23. How can we solve this issue?

template<traits::NonUnusedAttr T>
constexpr void move_to(T&, T&) noexcept
{
static_assert(
!std::is_const_v<T>,
"`x4::move_to(T const&, T const&)` is not allowed"
);
static_assert(
false,
"lvalue reference detected on the `src` argument of `x4::move_to`. "
"The caller is definitely lacking `std::move` or `std::forward`. If you "
"intend to *copy* the mutable value, apply `x4::move_to(std::as_const(attr_), attr)`."
);
// Banned: possible, but bug-prone.
// dest = std::move(src);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions