workaround for an issue with gcc 8.1.0 (#146 - fix #145)

This commit is contained in:
Paul Gruenbacher
2018-10-27 23:43:24 +02:00
committed by Michele Caini
parent 5859a18b3a
commit c00cde8bcc
+7 -15
View File
@@ -4,6 +4,7 @@
#include <vector>
#include <memory>
#include <cassert>
#include <utility>
#include <algorithm>
#include <type_traits>
@@ -57,12 +58,16 @@ class scheduler final {
struct continuation final {
continuation(process_handler *handler)
: handler{handler}
{}
{
assert(handler);
}
template<typename Proc, typename... Args>
continuation then(Args &&... args) {
static_assert(std::is_base_of_v<process<Proc, Delta>, Proc>);
handler = scheduler::then<Proc>(handler, std::forward<Args>(args)...);
auto proc = typename process_handler::instance_type{new Proc{std::forward<Args>(args)...}, &scheduler::deleter<Proc>};
handler->next.reset(new process_handler{std::move(proc), &scheduler::update<Proc>, &scheduler::abort<Proc>, nullptr});
handler = handler->next.get();
return *this;
}
@@ -104,17 +109,6 @@ class scheduler final {
delete static_cast<Proc *>(proc);
}
template<typename Proc, typename... Args>
static auto then(process_handler *handler, Args &&... args) {
if(handler) {
auto proc = typename process_handler::instance_type{new Proc{std::forward<Args>(args)...}, &scheduler::deleter<Proc>};
handler->next.reset(new process_handler{std::move(proc), &scheduler::update<Proc>, &scheduler::abort<Proc>, nullptr});
handler = handler->next.get();
}
return handler;
}
public:
/*! @brief Unsigned integer type. */
using size_type = typename std::vector<process_handler>::size_type;
@@ -186,11 +180,9 @@ public:
template<typename Proc, typename... Args>
auto attach(Args &&... args) {
static_assert(std::is_base_of_v<process<Proc, Delta>, Proc>);
auto proc = typename process_handler::instance_type{new Proc{std::forward<Args>(args)...}, &scheduler::deleter<Proc>};
process_handler handler{std::move(proc), &scheduler::update<Proc>, &scheduler::abort<Proc>, nullptr};
handlers.push_back(std::move(handler));
return continuation{&handlers.back()};
}