C++ Core Guidelines # GSL: Guidelines support library
Summary of GSL components:
GSL.view: Views
These types allow the user to distinguish between owning and non-owning pointers and between pointers to a single object and pointers to the first element of a sequence.
NOTE:
一、"owning and non-owning pointers"告诉我们需要阐明清楚ownership,它的实现是通过
gsl::owner
来实现的。二、"pointers to a single object and pointers to the first element of a sequence"告诉我们需要区分清楚range,它的实现主要是通过
gsl::span
在 microsoft/GSL 中,"GSL.view: Views"包含的内容进行了梳理:
1. Views owner ☑ an alias for a raw pointer not_null ☑ restricts a pointer / smart pointer to hold non-null values span ☑ a view over a contiguous sequence of memory. Based on the standardized verison of std::span
, howevergsl::span
enforces bounds checking. See the wiki for additional information.span_p ☐ spans a range starting from a pointer to the first place for which the predicate is true basic_zstring ☑ A pointer to a C-string (zero-terminated array) with a templated char type zstring ☑ An alias to basic_zstring
with a char type ofchar
czstring ☑ An alias to basic_zstring
with a char type ofconst char
wzstring ☑ An alias to basic_zstring
with a char type ofwchar_t
cwzstring ☑ An alias to basic_zstring
with a char type ofconst wchar_t
u16zstring ☑ An alias to basic_zstring
with a char type ofchar16_t
cu16zstring ☑ An alias to basic_zstring
with a char type ofconst char16_t
u32zstring ☑ An alias to basic_zstring
with a char type ofchar32_t
cu32zstring ☑ An alias to basic_zstring
with a char type ofconst char32_t
TODO
stackoverflow What “are” the C++ GSL guidelines?
modernescpp C++ Core Guideline: The Guideline Support Library
gsl library implementation
gsl-lite
特点:
1、C++98、C++11