-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidget.cpp
More file actions
31 lines (26 loc) · 866 Bytes
/
widget.cpp
File metadata and controls
31 lines (26 loc) · 866 Bytes
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
28
29
30
31
#include "widget.h"
#include "gadget.h"
#include <string>
#include <vector>
struct Widget::implementation {
std::string name;
std::vector<double> data;
Gadget g1, g2, g3;
};
Widget::Widget() : implementation_ptr(std::make_unique<implementation>()) {}
Widget::~Widget() = default;
Widget::Widget(const Widget &rhs) : implementation_ptr(nullptr) {
if (rhs.implementation_ptr)
implementation_ptr = std::make_unique<implementation>(*rhs.implementation_ptr);
}
Widget& Widget::operator=(const Widget &rhs) {
if (!rhs.implementation_ptr)
implementation_ptr.reset();
else if (!implementation_ptr)
implementation_ptr = std::make_unique<implementation>(*rhs.implementation_ptr);
else
*implementation_ptr = *rhs.implementation_ptr;
return *this;
}
Widget::Widget(Widget &&rhs) = default;
Widget& Widget::operator=(Widget &&rhs) = default;