Skip to main content
6 votes
2 answers
282 views

When I have some const members variables in my class, I would like to know how to respect core guideline C.12 to keep a default copy-assignment operator. C.12: Don’t make data members const or ...
kingsjester's user avatar
8 votes
2 answers
274 views

I haven't found a video about const all the things ¹, but there's at least Con.3: By default, pass pointers and references to consts from the Cpp Core Guidelines. There's lots of presentations and ...
Enlico's user avatar
  • 30.3k
3 votes
1 answer
260 views

There is the following C++ Core Guideline: Header files should be self-contained In large project, how can we automate this check, I would like to avoid having to add empty .cpp files for every &...
darune's user avatar
  • 11.5k
3 votes
1 answer
242 views

According to the C++ Core Guidelines, rule C.46: By default, declare single-argument constructors explicit. The reason is to avoid unintended conversions. However, why is the explicit keyword ...
toliveira's user avatar
  • 1,857
2 votes
1 answer
166 views

Consider the following code: #include <string> auto f1(auto&& v) { return v; } auto f2(auto&& v) { return std::forward<decltype(v)>(v); } int main() { return ...
xmllmx's user avatar
  • 44.6k
4 votes
2 answers
236 views

We are using clang-tidy to do static analysis, and we've enabled cpp-core-guidelines. As per previous advice (by one of the authors of cpp-core-guidelines), we have a abstract base class with a ...
Werner Erasmus's user avatar
2 votes
1 answer
173 views

Cpp Core Guideline F19 tells us Flag a function that takes a TP&& parameter (where TP is a template type parameter name) and does anything with it other than std::forwarding it exactly once ...
pasbi's user avatar
  • 2,191
3 votes
1 answer
306 views

Clang-tidy (versions 13.x and 16.x) detects violations of cppcoreguidelines-pro-bounds-array-to-pointer-decay in a weirdly specific situation: when iterating over an array that is accessed through a ...
OLEGSHA's user avatar
  • 728
-3 votes
1 answer
366 views

C++ Core Guidelines, I.3: Avoid singletons: Exception You can use the simplest “singleton” (so simple that it is often not considered a singleton) to get initialization on first use, if any: X& ...
3CEZVQ's user avatar
  • 42.9k
1 vote
1 answer
130 views

The following code is invalid because it takes a pointer into a temporary object (triggering -Wdangling-gsl): static std::string f() { return "hi"; } void func() { const char* ptr = ...
StilesCrisis's user avatar
  • 16.4k
4 votes
1 answer
382 views

For code like this: #include <cstdint> extern const char *f(); extern void g(const uint8_t *); int main() { const char *p = f(); g(reinterpret_cast<const uint8_t *>(p)); } clang-...
user1244932's user avatar
  • 8,282
0 votes
2 answers
261 views

For example, can it be used in Qt for the following? gsl::owner<QWidget*> w{new QWidget{parent}} In this example, the ownership is shared by the new-site and the parent, because the code who ...
Johannes Schaub - litb's user avatar
1 vote
1 answer
1k views

In the C++ Core Guidelines std::optional is only referred once: If you need the notion of an optional value, use a pointer, std::optional, or a special value used to denote “no value.” Other than ...
Henk's user avatar
  • 866
0 votes
1 answer
144 views

Im new to c++, I'm reading the core guidelines and I came across this: P.1: Express ideas directly in code In this, it says to use something like Month month() const; instead of int month(); So I have ...
Johnathon's user avatar
  • 175
1 vote
1 answer
344 views

I have a function like this: void column(const std::string &value) { ... } void column(float value) { ... } template <class... TColumns> void row(const TColumns &...columns) { ImGui::...
Gasim's user avatar
  • 8,051

15 30 50 per page
1
2 3 4 5
7