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::spanenforces 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_zstringwith a char type ofcharczstring ☑ An alias to basic_zstringwith a char type ofconst charwzstring ☑ An alias to basic_zstringwith a char type ofwchar_tcwzstring ☑ An alias to basic_zstringwith a char type ofconst wchar_tu16zstring ☑ An alias to basic_zstringwith a char type ofchar16_tcu16zstring ☑ An alias to basic_zstringwith a char type ofconst char16_tu32zstring ☑ An alias to basic_zstringwith a char type ofchar32_tcu32zstring ☑ An alias to basic_zstringwith 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