Home | History | Annotate | Download | only in coroutine.handle
      1 // -*- C++ -*-
      2 //===----------------------------------------------------------------------===//
      3 //
      4 //                     The LLVM Compiler Infrastructure
      5 //
      6 // This file is dual licensed under the MIT and the University of Illinois Open
      7 // Source Licenses. See LICENSE.TXT for details.
      8 //
      9 //===----------------------------------------------------------------------===//
     10 
     11 // UNSUPPORTED: c++98, c++03, c++11
     12 
     13 #include <experimental/coroutine>
     14 
     15 namespace coro = std::experimental;
     16 
     17 struct A {
     18   using promise_type = A*;
     19 };
     20 
     21 struct B {};
     22 struct C {};
     23 
     24 namespace std { namespace experimental {
     25   template <>
     26   struct coroutine_traits<::A, int> {
     27     using promise_type = int*;
     28   };
     29   template <class ...Args>
     30   struct coroutine_traits<::B, Args...> {
     31     using promise_type = B*;
     32   };
     33   template <>
     34   struct coroutine_traits<::C> {
     35     using promise_type = void;
     36   };
     37 }}
     38 
     39 template <class Expect, class T, class ...Args>
     40 void check_type() {
     41   using P = typename coro::coroutine_traits<T, Args...>::promise_type ;
     42   static_assert(std::is_same<P, Expect>::value, "");
     43 };
     44 
     45 int main()
     46 {
     47   check_type<A*, A>();
     48   check_type<int*, A, int>();
     49   check_type<B*, B>();
     50   check_type<void, C>();
     51 }
     52