Should I use the Guidelines Support Library (GSL) in a new C++ project?

2.1k Views Asked by At

What are the pros and cons in favor of and against using the Guidelines Support Library (GSL) in a new C++ project? I find some constructs there very attractive but am a bit scared of including and relying on such a fundamental library.

1

There are 1 best solutions below

5
On

The GSL is just a support library for the C++ core guidelines. If you are using the GSL, then these core guidelines should be the guidelines you apply to your code (not Google's or any other found online). You don't need the GSL for the core guidelines nor do you need to use everything in the GSL. Personnally I have started using it for simple bits like index and not_null.

The GSL is not perfect, there are many things that could/should be added, it doesn't impede me for doing crazy things, but it helps adding a framework/some kind of verification to what I'm doing. Also it removes the signed/unsigned issues with index.

I would advise to use it in a new project, as its run-time overhead should be null, but it's a matter of taste. If your project has lots of new developers (or toddlers), then it's something considering to help them growing up.