1 // { dg-lto-do link } 2 // { dg-lto-options { { -std=gnu++14 -flto -g -Wno-return-type } { -std=gnu++14 -flto -g -O2 -fno-inline -flto-partition=max -Wno-return-type } } } 3 // { dg-extra-ld-options "-r -nostdlib" } 4 5 namespace std { 6 inline namespace __cxx11 {} 7 template <typename _Tp, _Tp> struct integral_constant { 8 static constexpr _Tp value = 0; 9 }; 10 template <typename> struct __and_; 11 struct is_member_object_pointer : integral_constant<bool, false> {}; 12 template <typename> 13 struct is_member_function_pointer : integral_constant<bool, false> {}; 14 template <typename> struct remove_reference { typedef int type; }; 15 template <typename> class C; 16 template <bool, int, typename...> struct __result_of_impl; 17 template <typename _Functor, typename... _ArgTypes> 18 struct __result_of_impl<false, 0, _Functor, _ArgTypes...> { 19 typedef decltype(0) type; 20 }; 21 template <typename _Functor, typename... _ArgTypes> 22 struct C<_Functor(_ArgTypes...)> 23 : __result_of_impl<is_member_object_pointer::value, 24 is_member_function_pointer< 25 typename remove_reference<_Functor>::type>::value, 26 _Functor> {}; 27 template <typename _Tp> using result_of_t = typename C<_Tp>::type; 28 template <typename> void forward() { } 29 template <typename _Tp> _Tp move(_Tp) {} 30 namespace __cxx11 { 31 class basic_string typedef string; 32 } 33 template <typename> struct allocator_traits { typedef decltype(0) pointer; }; 34 } 35 struct F : std::allocator_traits<int> {}; 36 namespace std { 37 namespace __cxx11 { 38 class basic_string { 39 public: 40 struct _Alloc_hider : F { 41 _Alloc_hider(pointer); 42 } _M_dataplus; 43 basic_string(int) : _M_dataplus(0) {} 44 ~basic_string(); 45 }; 46 } 47 template <typename> class function; 48 template <typename _Functor> class _Base_manager { 49 protected: 50 static _Functor *_M_get_pointer(int) {} 51 }; 52 template <typename, typename> class _Function_handler; 53 template <typename _Res, typename _Functor, typename... _ArgTypes> 54 class _Function_handler<_Res(_ArgTypes...), _Functor> 55 : _Base_manager<_Functor> { 56 public: 57 static _Res _M_invoke(const int &) { 58 (*_Base_manager<_Functor>::_M_get_pointer(0))(); 59 } 60 }; 61 template <typename, typename> using __check_func_return_type = int; 62 template <typename _Res, typename... _ArgTypes> 63 class function<_Res(_ArgTypes...)> { 64 template <typename> using _Invoke = decltype(0); 65 template <typename _Functor> 66 using _Callable = __and_<__check_func_return_type<_Invoke<_Functor>, _Res>>; 67 template <typename, typename> using _Requires = int; 68 69 public: 70 template <typename _Functor, typename = _Requires<_Callable<_Functor>, void>> 71 function(_Functor); 72 using _Invoker_type = _Res (*)(const int &); 73 _Invoker_type _M_invoker; 74 }; 75 template <typename _Res, typename... _ArgTypes> 76 template <typename _Functor, typename> 77 function<_Res(_ArgTypes...)>::function(_Functor) { 78 _M_invoker = _Function_handler<_Res(), _Functor>::_M_invoke; 79 } 80 class unique_ptr { 81 public: 82 ~unique_ptr(); 83 }; 84 template <typename _Tp, typename... _Args> _Tp make_unique(_Args... __args) { 85 _Tp(__args...); 86 } 87 } 88 class A { 89 public: 90 template <class T> T as(); 91 }; 92 class variables_map { 93 public: 94 A operator[](std::basic_string); 95 }; 96 class B { 97 public: 98 variables_map configuration(); 99 void run(int, int, std::function<void()>); 100 }; 101 class H; 102 struct G { 103 enum {} _state; 104 }; 105 class D { 106 G _local_state; 107 std::unique_ptr _task; 108 template <typename Func> void schedule(Func func) { 109 struct task_with_state { 110 task_with_state(Func func) : _func(func) {} 111 Func _func; 112 } tws = std::make_unique<task_with_state>(std::move(func)); 113 } 114 friend H; 115 }; 116 template <typename> using futurize_t = H; 117 class H { 118 D *_promise; 119 template <typename Func> void schedule(Func func) { 120 G __trans_tmp_1; 121 struct task_with_ready_state { 122 task_with_ready_state(Func, G) { }; 123 }; 124 std::make_unique<task_with_ready_state>(std::move(func), __trans_tmp_1); 125 _promise->schedule(std::move(func)); 126 } 127 template <typename Func, typename Param> void then(Func func, Param) { 128 using P = D; 129 P pr; 130 schedule([ pr = std::move(pr), func, param = std::forward<Param> ]{}); 131 } 132 133 public: 134 template <typename Func> futurize_t<std::result_of_t<Func()>> then(Func) { 135 then(0, [] {}); 136 } 137 } clients; 138 int main() { 139 B app; 140 app.run(0, 0, [&] { 141 auto config = app.configuration()[0].as<std::string>(); 142 clients.then([] {}); 143 }); 144 145 return 0; 146 } 147