Improved pimpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <memory>
class MyClassImpl;
class MyClass
{
public:
explicit MyClass();
~MyClass();
// movable:
MyClass(MyClass && rhs) noexcept;
MyClass& operator=(MyClass && rhs) noexcept;
// and copyable:
MyClass(const MyClass& rhs);
MyClass& operator=(const MyClass& rhs);
void DoSth();
void DoConst() const;
private:
// const access:
const MyClassImpl* Pimpl() const { return m_pImpl.get(); }
MyClassImpl* Pimpl() { return m_pImpl.get(); }
std::unique_ptr<MyClassImpl> m_pImpl;
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX