鍍金池/ 問答/C  C++/ 裸指針形參可以接受unique_ptr實參嗎?

裸指針形參可以接受unique_ptr實參嗎?

// suppoese I have
void test(int * ptr);
auto p = std::make_unique<int>(1); // already supported in C++14

// can I call this?
test(p);
回答
編輯回答
使勁操

不可以。請使用:

test(p.get());
2017年9月6日 05:00