• Forum
  • Lounge
  • C++ Core Guideline - the Guideline Suppo

 
C++ Core Guideline - the Guideline Support Library

I notice it is (somewhat) common for someone to mention a part of the C++ Common Guideline when making about point about using a particular part of C++.

I've also run across lots of references to a Guideline Support Library. Several implementations, most mentioned is the one by Microsoft.

Is the Core Guideline/GSL something I should investigate and use with new code I write whenever possible?

I'm looking for opinions from those I consider the more experienced programmers here such as (not an exhaustive list by any means and maybe wrong spelling) Duthomas, JLBorges, mbozzi, kbw, helios, seeplus....

I don't see a lot of "treat me like a 3 year old" style tutorials on using the GSL, at least nothing I could easily find in my admittedly simple interwebz searching.
Last edited on
BTW, this is a "shout out" of thanks to seeplus....

A while back you mentioned Rainer Grimm had published a new book, "C++ Core Guidelines Explained: Best Practices for Modern C++," and I had whinged at the time there was no eBook that wasn't Amazon mobi format only. I like having a print and eBook copy. The cost via Amazon for both was for me ex-pen-sive!

informit.com is an online book retailer, the site also allows for registering books purchased elsewhere.

While registering a book I had purchased years ago I noticed they had his book for sale, in a print/eBook bundle, that wasn't such an outrageous combined price.

So I slapped the bundle into my cart. While checking out for the purchase my account apparently had an unused discount voucher! Well, hot damn! Use that sucker!

My final cost for the bundle with US state sales tax was less than what I would have paid for just the print book at Amazon!! Yippee!!!!
On Grimm's blog he has previously covered most (if not all) of the core guidelines. The book is mainly a collection of the blog posts on this topic (with some extras etc).

http://www.modernescpp.com/index.php/der-einstieg-in-modernes-c

and see the section on core guidelines
I like having the info in a collected reference. :)

I know the book is about explaining an online document, https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines.

The explanations and extras help make me like the book. I'm enjoying reading it, comparing his text and English explanations to the C++ Core Guidelines web page.
A GSL is hosted at https://github.com/microsoft/GSL

The core guidelines should be born in mind when writing code in C++. Any deviation should be recognised as being against these guidelines.
One of the most cited example from the C++CG is about using namespace std; when explaining to people learning C++ whether to use it or not.

(Paraphrase): "it's OK at a local scope" and "don't use it in a header file" and that's supposedly that.

For me that leaves out a key idea.

The use of using namespace std; leaves the programmer open to a name clash with a name from the standard library
followed by an example and
However, this is not particularly likely to lead to a resolution that is not an error and people who use using namespace std are supposed to know about std and about this risk.

Someone learning C++ doesn't know the possible risk. For me that is why I make it a Rule Zero of not having it in code I write.

I don't consider it an error, just not good code. It's for "transitioning" old code to new, better code IMO.
Last edited on
I know about the Microsoft GSL. :) Shoved sideways into my Visual Studio installs via vcpkg.

I just need a bit of assistance in "how to use" written for someone that prefers well-documented simple examples.

And glancing at Chapter 20 of his book it looks like there are the explanations and examples I am looking for. :D
Last edited on
Herr Grimm mentions at the start of Chapter 20 another GSL library, GSL-Lite: https://github.com/gsl-lite/gsl-lite/

Header-only and usable C++98! Suh-weet!
George P wrote:
Someone learning C++ doesn't know the possible risk.

yes, but Core Guidelines says in the beginning "These guidelines are not intended to be a substitute for a tutorial treatment of C++."
Topic archived. No new replies allowed.