Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Hot answers tagged

7 votes
Accepted

In C++, how is signed integer stored?

In C++, how is signed integer stored? The C++ specification does not prescribe any particular storage representation for signed integers on the actual hardware level. An implementation is free to ...
user avatar
3 votes
Accepted

C++ Abstract classes vs selective compilation

That's good if you need just one implementation in a given binary In particular for differences based on the target device, since one expects a given binary to be running on a particular platform. I ...
user avatar
3 votes
Accepted

If an object x is an instance of a type T, then what is a type T for a concept C?

If you have classes A and B, and B is a derived class of A, that is a noun property. B has a fundamental relationship to A which the very definition of B must explicitly claim. Concepts don't work ...
user avatar
  • 11.5k
3 votes

If an object x is an instance of a type T, then what is a type T for a concept C?

A concept is a predicate. I'd use the term satisfies, as in A type T satisfies the concept C when... Many concepts specify requirements on the interface of a type. Taking a phrase from languages ...
user avatar
  • 9,784
3 votes

Performance hit after non-functional refactoring

You didn't say what percentage in performance change. And whether it is for a tight benchmark or as part of an application. You might see a function getting ten times slower - from 1 nanosecond to 10 ...
user avatar
  • 37.5k
2 votes
Accepted

Use aggregation like LSP in C++

First things first: the UML diagram The original diagram is syntactically correct (except for the <I> on the box boundary, which should be «interface» centered above Licence in plain UML). The ...
user avatar
  • 66.9k
2 votes

Use aggregation like LSP in C++

For a demo of the Liskov Substitution Principle the header for Billing would only have License. The point of the LSP is that any object that extends another doesn't break that base functionality. ...
user avatar
  • 13k
2 votes

Performance hit after non-functional refactoring

It's certainly plausible that moving definitions to a new translation unit has meant the optimiser couldn't do as well. You can #include whatever files you like, so you can re-create the old structure ...
user avatar
  • 9,784
1 vote

How would a SRP `class Car` look like?

There is no global answer to this, and in particular it depends on what your program is simulating. To take some highly simplified examples: If your Car represents a Formula 1 race car, you probably ...
user avatar
1 vote

is there a two-way (bidirectional) observer pattern?

The normal observer pattern can easily be used in a bidirectional way: One approach is that the two objects are reciprocal subjects and observers, i.e. both implement the two interfaces and register ...
user avatar
  • 66.9k
1 vote

Mocking clock in C++ unit test

Mocking the clock is difficult. The problem is, there are many system functions that check the time, and mocking them all may be impossible - with the result that different bits of code get ...
user avatar
  • 37.5k

Only top scored, non community-wiki answers of a minimum length are eligible