i began implementing n3558 on top of libc++ master (see future
here) stuck error in functional
, not understand.
no matter how code it, fails __compressed_pair
error. don't know whether missing or bug in libc++
.
the following code:
#include <future> struct test { test() { int someint = 0; std::promise<void> prom; auto fut = prom.get_future(); fut.then( [this, someint]( std::future<void> future ) { } ); } };
triggers in clang 3.3:
in file included /std/include/map:375: /std/include/functional:993:11: error: no matching constructor initialization of '__compressed_pair<<lambda @ /std/include/future:1096:14>, std::__1::allocator<<lambda @ /std/include/future:1096:14> > >' : __f_(piecewise_construct, _vstd::forward_as_tuple(_vstd::move(__f)), ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /std/include/functional:1278:26: note: in instantiation of member function 'std::__1::__function::__func<<lambda @ /std/include/future:1096:14>, std::__1::allocator<<lambda @ /std/include/future:1096:14> >, void ()>::__func' requested here ::new (__f_) _ff(_vstd::move(__f)); ^ /std/include/__functional_base:341:37: note: in instantiation of function template specialization 'std::__1::function<void ()>::function<<lambda @ /std/include/future:1096:14> >' requested here return _vstd::forward<_fp>(__f)(_vstd::forward<_args>(__args)...); ^ /std/include/__config:301:15: note: expanded macro '_vstd' #define _vstd std::_libcpp_namespace ^ /std/include/functional:1691:12: note: in instantiation of function template specialization 'std::__1::__invoke<const <lambda @ /std/include/future:1144:17> &, const <lambda @ /std/include/future:1096:14> &>' requested here return __invoke(__f, __mu(get<_indx>(__bound_args), __args)...); ^ /std/include/functional:1761:20: note: in instantiation of function template specialization 'std::__1::__apply_functor<const <lambda @ /std/include/future:1144:17>, const std::__1::tuple<<lambda @ /std/include/future:1096:14> >, 0, std::__1::tuple<> >' requested here return __apply_functor(__f_, __bound_args_, __indices(), ^ /std/include/future:1114:3: note: in instantiation of function template specialization 'std::__1::__bind<<lambda @ /std/include/future:1144:17>, <lambda @ /std/include/future:1096:14> >::operator()<>' requested here invoke_bind(); ^ /std/include/future:1148:22: note: in instantiation of function template specialization 'std::__1::__then<void>::bind<std::__1::future<void>, <lambda @ game/game_local.cpp:1020:9>, <lambda @ /std/include/future:1144:17> >' requested here return __then<_rp>::bind( fut, forward<f>(execute_func), move(invoker) ); ^ /std/include/future:1527:34: note: in instantiation of function template specialization 'std::__1::__then<void>::bind_async<std::__1::future<void>, <lambda @ game/game_local.cpp:1020:9> >' requested here {return __then<return_type>::bind_async( *this, std::forward<function>(func) );} ^ game/local.cpp:1020:3: note: in instantiation of function template specialization 'std::__1::future<void>::then<<lambda @ game/game_local.cpp:1020:9> >' requested here .then( [this, someint]( std::future<void> future ) { ^ /std/include/memory:2371:31: note: candidate constructor not viable: requires 0 arguments, 3 provided _libcpp_inline_visibility __compressed_pair() {} ^ /std/include/memory:2372:40: note: candidate constructor not viable: requires single argument '__t1', 3 arguments provided _libcpp_inline_visibility explicit __compressed_pair(_t1_param __t1) ^ /std/include/memory:2374:40: note: candidate constructor not viable: requires single argument '__t2', 3 arguments provided _libcpp_inline_visibility explicit __compressed_pair(_t2_param __t2) ^ /std/include/memory:2376:31: note: candidate constructor not viable: requires 2 arguments, 3 provided _libcpp_inline_visibility __compressed_pair(_t1_param __t1, _t2_param __t2) ^ /std/include/memory:2357:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, 3 provided class __compressed_pair ^ /std/include/memory:2357:7: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, 3 provided
compiling gcc 4.8 gives far uglier error message, it's same.
could shed light?
basically, interesting part happens when try invoke binding of invoker bind_async (future:1144). lambda takes std::function argument, binding has lambda there. constructs parameter lambda, internally creates type erasure subclass _function::_func. __func stores both lambda , allocator, , not waste space when using stateless allocator, uses __compressed_pair. tries construct compressed_pair piecewise_construct constructor, , fails find one.
why fail find one? constructor in question (in memory:2416) under #if block, specifically
#ifndef _libcpp_has_no_variadics
so i'm going assume somehow symbol got defined in build. passing -std=c++11 compiler? if yes (and how else other stuff compile?), maybe need double-check config of libc++. in case, should try adding #else preprocessor block above , putting #error in there, make sure problem you're having.
Comments
Post a Comment