Questions tagged [c++]

For questions about C++'s design, or languages which are closely related to C++

Filter by
Sorted by
Tagged with
3 votes
1 answer
209 views

Concept Overloading in C++

The meaning of function overloading is that two or more functions can have the same name but different parameters. In C++20, concept has been introduced. I found ...
JimmyHu's user avatar
  • 133
5 votes
4 answers
422 views

Why does C++ allow extra arguments to printf?

In the C++ standard library, the format and printf functions specifically accept extraneous arguments: It is not an error to ...
Deborah C's user avatar
24 votes
3 answers
6k views

Why are volatile objects so difficult to work with in C++?

C++ does not generate default copy/move constructors or assignment operators for any volatile struct or ...
Bbrk24's user avatar
  • 8,857
14 votes
4 answers
3k views

When would a Java style enum be better than a C++ style enum, and vice versa?

In Java, enum values behave like objects (since they are basically syntactic sugar for objects) and they can have their own class methods. In C++, however, enums are essentially an alias for an ...
FireTheLost's user avatar
  • 1,583
6 votes
3 answers
797 views

Why might a language avoid reallocation?

In Java, the size of arrays are immutable. However, to my understanding, they are still allocated on the heap, because Java allocates almost everything on the heap. Even then, Java arrays are still ...
user16217248's user avatar
  • 7,535
15 votes
8 answers
5k views

Why would a language need to have trap representations?

In C there is a concept of trap representations, or non-value representations. If such a value is produced or used, immediate undefined behavior is invoked. This is one of the dangers of using ...
user16217248's user avatar
  • 7,535
19 votes
4 answers
5k views

What obstacles prevented C and C++ from standardizing π?

C does not even have M_PI standardized. C++ only added std::numbers::pi very recently. Yes, the fact that this took so long does ...
user16217248's user avatar
  • 7,535
6 votes
1 answer
167 views

Automatic copy to move promotion

I'm designing a language that has move semantics similar to C++. To make it more efficient and to prevent the need for explicit moves I want to automatically promote copies to moves if the compiler ...
chrysante's user avatar
  • 748
3 votes
3 answers
426 views

What are the pros and cons of SFINAE?

SFINAE stands for Substitution Failure Is Not An Error. It's widely used by C++ in template resolution, where it has two major consequences: If a specific template instantiation is invalid, but there ...
Bbrk24's user avatar
  • 8,857
6 votes
2 answers
235 views

How are C++ style references implemented behind the scenes? Could they be implemented without pointers?

I would not be surprised if C++ style int &y = x; was no more than int *y = &x; behind the scenes and every use of ...
user16217248's user avatar
  • 7,535
7 votes
1 answer
167 views

Disjoint language extensions (C++ and Objective-C)

Objective-C and C++ are both extensions of C (or at least started out to be). So for the purpose of this question I allow myself the slightly inaccurate assumption that both languages are pure ...
chrysante's user avatar
  • 748
6 votes
2 answers
621 views

Why does C++ require private methods to be declared with public ones?

C++ and Objective-C both require forward declaration of the methods and fields on a class. Objective-C lets you hide the existence of internal/private methods & fields altogether: ...
Bbrk24's user avatar
  • 8,857
2 votes
1 answer
319 views

How does the C++ Committee generally decide what does or doesn't go in its standard library?

I want to learn from how some existing, well-known, well-established languages define their standard libraries. As a first step- before getting in to the deeper "why" questions, I want to ...
starball's user avatar
  • 1,642
7 votes
1 answer
228 views

What can be learned from problems (and associated solutions / goals to strive for) C++ committee members have identified with their proposal culture?

C++ has a proposal process for changes to the language and standard library (see also the ISO C++ wiki's page on "How To Submit a Proposal", the Std Proposals mailing list, the list of ...
starball's user avatar
  • 1,642
31 votes
8 answers
3k views

Why would a language have a concept of undefined behavior instead of raising an error?

Certain constructs or conditions in programming just are not allowed. Languages such as Java or Swift handle these by raising an error when encountered. C and C++ on the other hand say 'Anything could ...
user16217248's user avatar
  • 7,535