Skip to content

std::is_nothrow_move_constructible_v<fu2::unique_function<void()>> possible? #23

@Hans-Giebenrath

Description

@Hans-Giebenrath

@Naios

Would it be possible to support

static_assert(std::is_nothrow_move_constructible_v<fu2::unique_function<void()>>);

?
I tried it with gcc (GCC) 8.2.1 20181127 and clang version 7.0.1 (tags/RELEASE_701/final) on Arch Linux. My use case is to store fu2::unique_functions in a std::vector, but upon resizing the vector, the assertion

assert(std::is_copy_constructible<T>::value && "The box is required to be copyable here!");

triggers, since the vector copies the elements to the new storage instead of moving.
I don't understand the internals enough to reason about the feasability of this feature. As a workaround, preallocating enough storage in the vector works for me, as well as wrapping fu2::unique_function into a std::unique_ptr, so this feature is more a Quality Of Life improvement.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions