C++20 coroutine_traitsC++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 C++20 coroutine_traits

Сообщение Anonymous »

Я изучаю концепцию cppreference и std::coroutine_traits.
На основании документации описание следующее

Код: Выделить всё

Determines the promise type from the return type and parameter types of a coroutine. The standard library implementation provides a publicly accessible member type promise_type same as R::promise_type if the qualified-id is valid and denotes a type. Otherwise, it has no such member.

Program-defined specialisations of coroutine_traits must define a publicly accessible nested type promise_type, otherwise the program is ill-formed.
Notes
If the coroutine is a non-static member function, then the first type in Args... is the type of the implicit object parameter, and the rest are parameter types of the function (if any).

If std::coroutine_traits::promise_type does not exist or is not a class type, the corresponding coroutine definition is ill-formed.

Users may define explicit or partial specializations of coroutine_traits dependent on program-defined types to avoid modification to return types.
Есть ли пример использования этого, когда сопрограмма является нестатическим членом функции? Какова цель этого?

Подробнее здесь: https://stackoverflow.com/questions/791 ... ine-traits
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»