Calling inherited template constructor of unique_ptr subclass

后端 未结 1 1138
野的像风
野的像风 2021-01-22 14:25

This is not a duplicate of questions on template constructors or even on calling inherited template constructors.

It is specifically about calling the inherited construc

相关标签:
1条回答
  • 2021-01-22 15:13

    std::unique<int> is meant to be smart pointer for ints, i.e. a replacement for int*.

    When you use std::unique<int*>, the pointer needs to be int**.

    Instead of

    using B = std::unique_ptr<int *, decltype(&::free)>;
    

    use

    using B = std::unique_ptr<int, decltype(&::free)>;
    

    Working code (Thanks, @CompuChip): http://ideone.com/ul29vr.

    0 讨论(0)
提交回复
热议问题