From 96adeed49a64f178089611ba8baaa6661df89ff2 Mon Sep 17 00:00:00 2001 From: Daniel Brosche Date: Tue, 28 Sep 2021 11:08:16 +0200 Subject: [PATCH 1/2] BUGFIX: Function copy construction fails based on Function& or const Function& (based on Linux/GCC 6.3.0) --- Function.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Function.h b/Function.h index 19a5e9e..80ddceb 100644 --- a/Function.h +++ b/Function.h @@ -37,12 +37,14 @@ template class Function(&data), const_cast(&other.data), Operation::Clone); invoker = other.invoker; manager = other.manager; } } + Function(Function& other) { other.swap(*this); } + Function(Function &&other) { other.swap(*this); } template Function(F &&f) { From 7d3d0b1a639056c2ddfafb118ad4e82c1400d0bd Mon Sep 17 00:00:00 2001 From: Daniel B Date: Wed, 6 Oct 2021 10:52:15 +0200 Subject: [PATCH 2/2] improve copy construction support for const Function& and Function& argument --- Function.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Function.h b/Function.h index 80ddceb..2d53582 100644 --- a/Function.h +++ b/Function.h @@ -37,13 +37,13 @@ template class Function(&data), const_cast(&other.data), Operation::Clone); + other.manager(&data, &other.data, Operation::Clone); invoker = other.invoker; manager = other.manager; } } - Function(Function& other) { other.swap(*this); } + Function(Function &other) : Function(const_cast(other)) {} Function(Function &&other) { other.swap(*this); } @@ -110,7 +110,7 @@ template class Function::type; template @@ -120,10 +120,10 @@ template class Function - static void manage(void *dest, void *src, Operation op) { + static void manage(void *dest, const void *src, Operation op) { switch (op) { case Operation::Clone: - new (dest) F(*static_cast(src)); + new (dest) F(*static_cast(src)); break; case Operation::Destroy: static_cast(dest)->~F();