Stroustrup gave a talk last year about his GSL (Guideline Support Library). There is an implementation by Micosoft at https://github.com/Microsoft/GSL . I was under the impression that the GSL was supposed to advise on bad coding style, and suggest improvements.
To this end, I installed MSFT's GSL and created a C++ file:
#include <stdio.h>
#include <gsl.h>
int main()
{
int *i = new int;
puts("hello world");
}
and built it using the Makefile:
msft : msft.cc
g++ -std=gnu++14 -I ../../src/GSL/include $^ -o $@
.PHONY : clean
clean :
rm -f msft
Obviously, there is a resource leak in the code caused by the new
.
So now I'm confused.
The GNU Scientific Library (GSL) is a numerical library for C and C++ programmers. It is free software under the GNU General Public License. The library provides a wide range of mathematical routines such as random number generators, special functions and least-squares fitting.
gsl::owner<T*> marks a pointer that has ownership of the referenced object. You should use gsl::owner<T> if you can not use resource handles such as smart pointers or containers. The key point about the owner is that you have to free the resource explicitly.
gsl-lite is a single-file header-only implementation of the C++ Core Guidelines Support Library originally based on Microsoft GSL and adapted for C++98, C++03.
The default location of the `gsl' directory is `/usr/local/include/gsl'.
The Guidelines Support Library (see also gsl-lite as an alternative) is a C++ library that implements some of the functions and classes recommended in the C++ Core Guidelines. A document with advice on how to use modern C++. It is worthwhile reading or skimming over the C++ Core Guidelines if you want to improve your use of C++. Using the GSL library is less important, but could be useful if you find yourself implementing code that is already in it. The C++ Core Guidelines have been around for a few years now, so some things, such as string_view, are already available (depending on what version of C++ you are compiling to) and do not require an external library to use.
You must use them as suggested in the CppCoreGuidelines.
Read them, understand how it applies to your codebase/programming habits/problems.
Visual Studio 2015 has plugins which help you to check if your code behaves well according to GSL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With