Skip to content

Commit

Permalink
docs: 为 30 题添加说明
Browse files Browse the repository at this point in the history
Signed-off-by: YdrMaster <[email protected]>
  • Loading branch information
YdrMaster committed Dec 24, 2024
1 parent 326e8fa commit 904dff0
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions exercises/30_std_unique_ptr/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "../exercise.h"
#include <cstring>
#include <memory>
#include <string>
#include <vector>
Expand All @@ -22,21 +23,15 @@ class Resource {

using Unique = std::unique_ptr<Resource>;
Unique reset(Unique ptr) {
if (ptr) {
ptr->record('r');
}
if (ptr) ptr->record('r');
return std::make_unique<Resource>();
}
Unique drop(Unique ptr) {
if (ptr) {
ptr->record('d');
}
if (ptr) ptr->record('d');
return nullptr;
}
Unique forward(Unique ptr) {
if (ptr) {
ptr->record('f');
}
if (ptr) ptr->record('f');
return ptr;
}

Expand All @@ -57,6 +52,7 @@ int main(int argc, char **argv) {
std::vector<const char *> answers[]{
{"fd"},
// TODO: 分析 problems[1] 中资源的生命周期,将记录填入 `std::vector`
// NOTICE: 此题结果依赖对象析构逻辑,平台相关,提交时以 CI 实际运行平台为准
{"", "", "", "", "", "", "", ""},
{"", "", "", "", "", "", "", ""},
};
Expand Down

0 comments on commit 904dff0

Please sign in to comment.