Bugfix in util::function: forward the callable instead of moving it
This commit is contained in:
parent
4641c5d7d2
commit
c26cf898ca
1 changed files with 2 additions and 2 deletions
|
|
@ -175,7 +175,7 @@ namespace psemek::util
|
||||||
|
|
||||||
if constexpr (uses_static_storage<T>::value)
|
if constexpr (uses_static_storage<T>::value)
|
||||||
{
|
{
|
||||||
new (reinterpret_cast<T *>(&storage_)) T(std::move(f));
|
new (reinterpret_cast<T *>(&storage_)) T(std::forward<F>(f));
|
||||||
|
|
||||||
static vtable m = {
|
static vtable m = {
|
||||||
[](void * src, void * dst){ new (reinterpret_cast<T*>(dst)) T(std::move(*reinterpret_cast<T*>(src))); },
|
[](void * src, void * dst){ new (reinterpret_cast<T*>(dst)) T(std::move(*reinterpret_cast<T*>(src))); },
|
||||||
|
|
@ -187,7 +187,7 @@ namespace psemek::util
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*reinterpret_cast<T**>(&storage_) = new T(std::move(f));
|
*reinterpret_cast<T**>(&storage_) = new T(std::forward<F>(f));
|
||||||
|
|
||||||
static vtable m = {
|
static vtable m = {
|
||||||
[](void * src, void * dst){ *reinterpret_cast<T**>(dst) = *reinterpret_cast<T**>(src); *reinterpret_cast<T**>(src) = nullptr; },
|
[](void * src, void * dst){ *reinterpret_cast<T**>(dst) = *reinterpret_cast<T**>(src); *reinterpret_cast<T**>(src) = nullptr; },
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue