C++ Logo

std-discussion

Advanced search

Re: std::make_shared and type deduction

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Tue, 7 Jul 2020 22:53:03 +0200
Il 07/07/20 22:45, Jason McKesson via Std-Discussion ha scritto:
> Perhaps something like:
>
> auto foo_ptr = std::unique_ptr(external_library::make_foo());
>
> This works just fine in C++17 through class template argument deduction.

Note that in OP's code make_foo() does not return a pointer, but an
object. Moreover, unique_ptr(pointer) does not participate in CTAD (P0433):

> http://eel.is/c++draft/unique.ptr#single.ctor-6

HTH,
-- 
Giuseppe D'Angelo | giuseppe.dangelo_at_[hidden] | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

Received on 2020-07-07 15:56:23