|
@ -2,6 +2,7 @@ |
|
|
#include "gp/exception.hpp"
|
|
|
#include "gp/exception.hpp"
|
|
|
#include "gp/algorithm/tmp_manip.hpp"
|
|
|
#include "gp/algorithm/tmp_manip.hpp"
|
|
|
#include "gp/algorithm/move.hpp"
|
|
|
#include "gp/algorithm/move.hpp"
|
|
|
|
|
|
|
|
|
namespace gp{ |
|
|
namespace gp{ |
|
|
|
|
|
|
|
|
template <typename> |
|
|
template <typename> |
|
@ -83,11 +84,27 @@ namespace gp{ |
|
|
delete self.functor; |
|
|
delete self.functor; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if(t.state | ACTIVE) |
|
|
|
|
|
|
|
|
if(o">!(t.state & ACTIVE)) |
|
|
{ |
|
|
{ |
|
|
|
|
|
state = INACTIVE; |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if constexpr (!std::is_same_v<T, function<ret(args...)>>) { |
|
|
if constexpr (sizeof(callable<T>) <= sizeof(self)) |
|
|
if constexpr (sizeof(callable<T>) <= sizeof(self)) |
|
|
{ |
|
|
{ |
|
|
t.self.functor->inplace_copy(self.inplace); |
|
|
|
|
|
|
|
|
new((void*)self.inplace) callable<T>(t); |
|
|
|
|
|
state = (state_t)(ACTIVE | SOO); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
self.functor = new callable<T>(t); |
|
|
|
|
|
state = (state_t)(ACTIVE | NO_SOO); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
if(t.state & SOO) |
|
|
|
|
|
{ |
|
|
|
|
|
auto& ref = t.self.functor; |
|
|
|
|
|
ref->inplace_copy((char*)&self); |
|
|
state = (state_t)(ACTIVE | SOO); |
|
|
state = (state_t)(ACTIVE | SOO); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
@ -95,9 +112,7 @@ namespace gp{ |
|
|
self.functor = t.self.functor->all_copy(); |
|
|
self.functor = t.self.functor->all_copy(); |
|
|
state = (state_t)(ACTIVE | NO_SOO); |
|
|
state = (state_t)(ACTIVE | NO_SOO); |
|
|
} |
|
|
} |
|
|
return; |
|
|
|
|
|
} |
|
|
} |
|
|
state = INACTIVE; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function() |
|
|
function() |
|
@ -105,10 +120,10 @@ namespace gp{ |
|
|
state = INACTIVE; |
|
|
state = INACTIVE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template <typename T> |
|
|
|
|
|
|
|
|
template<typename T> |
|
|
function<>(T& t) |
|
|
function<>(T& t) |
|
|
{ |
|
|
{ |
|
|
if constexpr (!std::is_same_v<T, function>) { |
|
|
|
|
|
|
|
|
if constexpr (!std::is_same_v<T, function<ret(args...)>>) { |
|
|
if constexpr (sizeof(callable<T>) <= sizeof(self)) |
|
|
if constexpr (sizeof(callable<T>) <= sizeof(self)) |
|
|
{ |
|
|
{ |
|
|
new((void*)self.inplace) callable<T>(t); |
|
|
new((void*)self.inplace) callable<T>(t); |
|
@ -136,7 +151,7 @@ namespace gp{ |
|
|
template <typename T> |
|
|
template <typename T> |
|
|
function(T&& t) |
|
|
function(T&& t) |
|
|
{ |
|
|
{ |
|
|
if constexpr (!std::is_same_v<T, function>) { |
|
|
|
|
|
|
|
|
if constexpr (!std::is_same_v<T, function<ret(args...)>>) { |
|
|
if constexpr (sizeof(callable<T>) <= sizeof(self)) |
|
|
if constexpr (sizeof(callable<T>) <= sizeof(self)) |
|
|
{ |
|
|
{ |
|
|
new((void*)self.inplace) callable<T>(gp::move(t)); |
|
|
new((void*)self.inplace) callable<T>(gp::move(t)); |
|
|