From 7c5b3a5eccaeab7c3dea87ca17d09e64ffcb421e Mon Sep 17 00:00:00 2001 From: Pranav Sharma Date: Wed, 4 Sep 2019 19:16:16 -0700 Subject: [PATCH] Update coding guidelines to prefer using make_unique for heap allocations (unless where not possible). (#1730) * Mention OrtCreateSessionFromArray in C API doc * Fix perf test executable due to removal of certain C APIs * fix linux build * Avoid duplication * Update coding guidelines to prefer using make_unique for heap allocations (unless where not possible). --- docs/Coding_Conventions_and_Standards.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/Coding_Conventions_and_Standards.md b/docs/Coding_Conventions_and_Standards.md index d1819f952d..9484b3837f 100644 --- a/docs/Coding_Conventions_and_Standards.md +++ b/docs/Coding_Conventions_and_Standards.md @@ -26,6 +26,10 @@ Other * Don't use else after return. see: [https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return](https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return) * Don't overuse std::shared\_ptr. Use std::shared\_ptr only if it's not clear when and where the object will be deallocated. See also: [https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-shared_ptr](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-shared_ptr) * Avoid using the 'long' type, which could be either 32 bits or 64 bits. +* If there is a legitimate need to allocate objects on the heap, prefer using std::make_unique(). References for the reasoning: + * https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-make_unique + * https://herbsutter.com/2013/05/29/gotw-89-solution-smart-pointers/ + * https://abseil.io/tips/126 #### Clang-format