promise_base( std::allocator_arg_t, Allocator alloc) { typedef detail::shared_state_object< R, Allocator > object_type; typedef std::allocator_traits< typename object_type::allocator_type > traits_type; typedef pointer_traits< typename traits_type::pointer > ptrait_type; typename object_type::allocator_type a{ alloc }; typename traits_type::pointer ptr{ traits_type::allocate( a, 1) }; typename ptrait_type::element_type* p = ptrait_type::to_address(ptr); try { traits_type::construct( a, p, a); } catch (...) { traits_type::deallocate( a, ptr, 1); throw; } future_.reset(p); }
explicit packaged_task( std::allocator_arg_t, Allocator const& alloc, Fn && fn) { typedef detail::task_object< typename std::decay< Fn >::type, Allocator, R, Args ... > object_type; typedef std::allocator_traits< typename object_type::allocator_type > traits_type; typedef pointer_traits< typename traits_type::pointer > ptrait_type; typename object_type::allocator_type a{ alloc }; typename traits_type::pointer ptr{ traits_type::allocate( a, 1) }; typename ptrait_type::element_type* p = boost::to_address(ptr); try { traits_type::construct( a, p, a, std::forward< Fn >( fn) ); } catch (...) { traits_type::deallocate( a, ptr, 1); throw; } task_.reset(p); }
polymorphic_holder& operator=(Derived const& rhs) { ptr_.reset(boost::make_shared<Derived>(rhs)); return *this; }