回答編集履歴
1
追記
answer
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
C++17がないとちょっと[扱いづらく](https://cpprefjp.github.io/reference/memory/shared_ptr/op_at.html)なりますが
|
1
|
+
~~C++17がないとちょっと[扱いづらく](https://cpprefjp.github.io/reference/memory/shared_ptr/op_at.html)なりますが~~
|
2
|
+
C++17でないと`std::shared_ptr<char[]> buffer;`は使えないようでした。
|
2
3
|
|
3
4
|
```c++
|
4
5
|
std::shared_ptr<char[]> buffer;
|
@@ -8,4 +9,18 @@
|
|
8
9
|
int length = width * height;
|
9
10
|
buffer.reset(new char[length]);
|
10
11
|
}
|
11
|
-
```
|
12
|
+
```
|
13
|
+
|
14
|
+
----
|
15
|
+
|
16
|
+
C++14以前ですと
|
17
|
+
|
18
|
+
|
19
|
+
```c++
|
20
|
+
std::shared_ptr<char> buf;
|
21
|
+
void Create(int x, int y){
|
22
|
+
buf.reset(new char[x*y], std::default_delete<char[]>());
|
23
|
+
}
|
24
|
+
```
|
25
|
+
|
26
|
+
になります。
|