相关疑难解决方法(0)

`unique_ptr <T const []>`应该接受`T*`构造函数参数?

码:

#include <memory>
using namespace std;

struct T {};

T* foo() { return new T; }
T const* bar() { return foo(); }

int main()
{
    unique_ptr< T const >       p1( bar() );        // OK
    unique_ptr< T const [] >    a1( bar() );        // OK

    unique_ptr< T const >       p2( foo() );        // OK
    unique_ptr< T const [] >    a2( foo() );        // ? this is line #15
}
Run Code Online (Sandbox Code Playgroud)

Visual C++ 10.0和MinGW g ++ 4.4.1的示例错误:

[d:\dev\test]
> cl foo.cpp
foo.cpp …

c++ standards unique-ptr c++11

13
推荐指数
1
解决办法
799
查看次数

标签 统计

c++ ×1

c++11 ×1

standards ×1

unique-ptr ×1