프로그래밍

[C++] GSL:Guidelines Support library (2nd)

하루삼십만원 2020. 12. 11. 20:58
반응형

GSL.owner:Ownership pointers

● unique_ptr<T> //unique ownership: std::unique_ptr<T>

● shared_ptr<T> //shared ownership: std::shared_ptr<T> (a counted pointer)

● stack_array<T> //스택 할당 배열. elements의 수는 생성자에서 결정되고 그 후에 고정된다. elements들은 T가 const type이 아니면 변경될 수 있다.

● dyn_array<T> // 힙 할당 배열. elements의 수는 생성자에서 결정되고 그 후에 고정된다. elements들은 T가 const type이 아니면 변경될 수 있다. 기본적으로 elements를 할당하고 소유하는 span.

 

GSL.assert: Assertions

● Expects //precondition assertion. 현재 function bodies에 위치함. 나중에 declarations으로 옮겨야 한다.

              // Expects(p)는 ("p==true"인 경우를 제외하고는) program을 종료한다.

              // Expects는 몇몇 옵션의 통제하에 있다. (enforcement, error message, alternatives to termincate).

● Ensures // postcondition assertion. 현재 function bodies에 위치함. 나중에 declarations으로 옮겨야 한다.

 

GSL.util: Utilities

● finally // finally(f)는 f 를 invoke하는 소멸자를 가진 final_action{f} 를 만든다. 

● narrow_cast // narrow_cast<T>(x)는 static_cast<T>(x)이다.

● narrow // "static_cast<T>(x) == x"일 때, narrow_cast<T>(x)는 static_cast<T>(x)이다. 그렇지 않으면 narrowing_error를 throw한다.

● [[implicit]] // "Marker" single-argument 생성자를 명시적으로 불분명하게 만들기 위해 투입한다.

● move_owner // "p = move_owner(q)"는 "p = q"를 의미한다.

● joining_thread //join하는 std::thread의 RAII style version

● index //모든 container와 array indexing에 사용할 type (현재 ptrdiff_t를 위한 alias)

 

GSL.concept: Concepts

이러한 개념(type predicates)은 Andrew Sutton의 Origin library, the Range proposal 및 ISO WG21 Palo Alto TR에서 차용한 것이다. 그것들은 ISO C++ standard의 일부가 될 것과 매우 유사할 가능성이 있다. 표기법은 ISO WG21 Concepts TS의 표기법이다. 아래의 개념은 대부분 Rangers TS에 정의되어 있다.

 

● Range

● String

● Number

● Sortable

● EqualityComparable

● Convertible

● Common

● Boolean

● Integral

● SignedIntegral

● SemiRegular

● Regular

● TotallyOrdered

● Function

● RegularFunction

● Predicate

● Relation

 

GSL.ptr: Smart pointer concepts

● Pointer // *, ->, == 같은 type과 기본 생성자(기본 생성자는 singular "null" value으로 설정하는 것으로 한다.)

● Unique_pointer // Pointer와 매치되는 type, 이동 가능하나 복사는 되지 않는다.

● Shared_pointer // Pointer와 매치되는 type, 복사 가능하다.

 

isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#gslowner-ownership-pointers

 

C++ Core Guidelines

 

isocpp.github.io

 

반응형

'프로그래밍' 카테고리의 다른 글

[C++] GSL:Guidelines Support library (1st)  (0) 2020.12.10
[C++] Philosophy 11, 12 & 13  (0) 2020.12.04
[C++] Philosophy 9 & 10  (0) 2020.12.03
[C++] Philosophy 7 & 8  (0) 2020.12.02
[C++] Philosophy 5 & 6  (0) 2020.12.01