Questions tagged [cpp-core-guidelines]

The C++ Core Guidelines are a collaborative effort led by Bjarne Stroustrup, much like the C++ language itself. They are the result of many person-years of discussion and design across a number of organizations. Their design encourages general applicability and broad adoption but they can be freely copied and modified to meet your organization's needs.

The C++ Core Guidelines, managed from this GitHub repository, represent a recent attempt to define good practices for modern C++ development. The guidelines focus on rules which static analysis tools are capable of detecting.

Alongside the guidelines themselves is the guideline support library (GSL). While the guidelines do not go into explicit detail about the behavior of such features, the Microsoft implementation currently acts as the de-facto standard.

94 questions
3 answers

If a function returns an array by reference is it a decay to pointer?

In the sample code below ComputeSomething() returns a reference to an array. I was asked to use C++ core guidelines (NuGet package on MSVC toolchain) as an extra static analysis tool. On the return line of ComputeSomething() the static analysis tool…
  • 9
  • 3
1 answer

Is the C++ expression for_each(v, [](string x) syntactically correct?

Is the below expression valid for for_each()? for_each(v,[](string x){ cout<
  • 459
  • 5
  • 15
1 answer

Include directives order in source file and in header file

Which is the recommended order in which the #include directives are supposed to be listed? I could not find any answer in the C++ Core Guidelines For example, should they be ordered like this: #include "OtherHeaderInCurrentLib.h" #include…
  • 5,275
  • 2
  • 26
  • 64
1 answer

gsl::span - pointer to end

I need to pass a gsl::span to a function that expects a pointer to beginning and a pointer to end. I updated the function to use a gsl::span to avoid a do not use pointer arithmetic warning. So how do I get the pointer to the end? I am trying to…
Benilda Key
  • 2,836
  • 1
  • 22
  • 34
1 2 3 4 5 6