From 904dff0ccd5295dcd70de83ba90f4110335a4ffe Mon Sep 17 00:00:00 2001 From: YdrMaster Date: Tue, 24 Dec 2024 13:09:59 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E4=B8=BA=2030=20=E9=A2=98=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: YdrMaster --- exercises/30_std_unique_ptr/main.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/exercises/30_std_unique_ptr/main.cpp b/exercises/30_std_unique_ptr/main.cpp index ab75c801..9b98b579 100644 --- a/exercises/30_std_unique_ptr/main.cpp +++ b/exercises/30_std_unique_ptr/main.cpp @@ -1,4 +1,5 @@ #include "../exercise.h" +#include #include #include #include @@ -22,21 +23,15 @@ class Resource { using Unique = std::unique_ptr; Unique reset(Unique ptr) { - if (ptr) { - ptr->record('r'); - } + if (ptr) ptr->record('r'); return std::make_unique(); } 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; } @@ -57,6 +52,7 @@ int main(int argc, char **argv) { std::vector answers[]{ {"fd"}, // TODO: 分析 problems[1] 中资源的生命周期,将记录填入 `std::vector` + // NOTICE: 此题结果依赖对象析构逻辑,平台相关,提交时以 CI 实际运行平台为准 {"", "", "", "", "", "", "", ""}, {"", "", "", "", "", "", "", ""}, };