Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
Description
https://en.cppreference.com/w/cpp/container/span
This should be used instead of a such arguments T *ptr, size_t size, const std::vector<T> &v.
Especially pointer and size pair is harmful: easy to use incorrect, hard to read the code.
Class is non-owning! It's just a reference to something.
Do not use it for strings! Another things exists for strings: https://en.cppreference.com/w/cpp/string/basic_string_view
Suggestion to use are here https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
Looks good.
I wonder why we could not use span<const char*>(column_names, i). Why would it be any different from an array of pointers to something else than char?
I understood that the "not for strings" is referring to usage like span<char>(name, strlen(name)), but the example is an array of pointers to NUL-terminated strings.