C + + function pointer parameter pass error

光辉 韦 41 Reputation points
2021-03-07T01:41:01.87+00:00

include <iostream>

include <thread>

include<coroutine>

include<string>

include<concepts>

include <experimental/coroutine>

using namespace std;
using namespace std::experimental;

include <iostream>

include <coroutine>

template<class T, class...V>
auto Register();
template<class T>
struct generator
{
struct promise_type;
using handle = coroutine_handle<promise_type>;
struct promise_type
{
T current_value;
static auto get_return_object_on_allocation_failure() { return generator<T>{ nullptr }; }
auto get_return_object() { return generator<T>{ handle::from_promise(*this) }; }
auto initial_suspend() { return suspend_always{}; }
auto final_suspend() { return suspend_always{}; }
void unhandled_exception() { std::terminate(); }
void return_void() {}

    auto yield_value(T value)
    {
        current_value = value;
        return suspend_always{}; // 这是一个 awaiter 结构, 见第二篇文章
    }
};
bool move_next() { return coro ? (coro.resume(), !coro.done()) : false; };
T current_value() {
    if (move_next()) {
        return coro.promise().current_value;
    }
}
generator(generator<T>&) = delete;
generator(generator<T>&& rhs) : coro(rhs.coro) { rhs.coro = nullptr; }
~generator<T>()
{
    if (coro)
        coro.destroy();
}

public:
handle coro;
generator<T>(handle h) : coro(h) {};

};
template<class T,class...A>
generator<T>(*List)(T t, A...a);

define Coroutine generator

template<class T>
generator<T> f()
{
co_yield "Hi";
}
namespace Fine {
int i = 0;
}
//TODO : 写入代码
Coroutine<int>Function(int,int) {
co_yield 90;
}

int main() {
List<int, int>(12, 34);//Throw an exception
}

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,520 questions
{count} votes