【发布时间】:2016-08-18 10:45:36
【问题描述】:
我尝试制作 pimpl 模式:
//header
#include <memory>
class Table
{
public:
Table();
private:
class Impl;
std::unique_ptr<Impl> *m_impl;
};
//source
#include <vector>
#include "table.hpp"
struct Table::Impl {
Impl();
};
Table::Table()
: m_impl { std::make_unique<Impl>() }
{
}
但我得到一个错误:
table.cpp:9:错误:在初始化中无法将“大括号括起来的初始化列表”转换为“std::unique_ptr*”:m_impl { std::make_unique() }
我不明白我做错了什么以及如何解决它。
【问题讨论】:
标签: c++ c++14 pimpl-idiom