1,474 questions
Score of -6
0 answers
49 views
Why does Go require package declarations in every file if all files in a directory belong to the same package? [duplicate]
If they already know all files in a directory belong to the same package, why not remove package declarations entirely?
Score of 1
2 answers
234 views
What is the rationale for std::span::operator[] being explicitly undefined for out of bounds access?
Triggered by this question I was reading about out of bounds access via std::span::operator[] here:
If idx < size() is false, the behavior is undefined.(until C++26)
Why is it specified ...
Score of 6
3 answers
880 views
What impediments are there to the inclusion of the Networking TS in the C++26 standard?
As C++26 standard's timeline is getting near, I want to know:
What are the reason(s) for no built in support of networking in the C++ standard. That is, what exactly are the problems that lead to ...
Best practices
1
vote
1
replies
47
views
What are the pros and cons of a terse property/method-syntax?
In designing a language from scratch, should methods use a self variable to access properties and other methods? Or should they imply their target with .prop? Or should they treat properties as local ...
Score of 6
1 answer
215 views
Is binding-level mutability necessary for a borrow checker, or could Rust have supported type-level const like C++?
I am new to Rust and one thing that stands out to me is that in Rust, constness/mutability is not bound to the type, but to a particular variable. So, it seems to me like it would be impossible in ...
Score of 1
1 answer
199 views
Why is it impossible to cast ref-unqualified member function pointer to a ref-qualified member function pointer?
This code is rejected by all compilers I could test it on, so I suppose it is ill-formed according to the standard.
struct X {
void f();
};
void (X::*fptr)() & = &X::f; // ERROR
Here we ...
Score of 59
1 answer
5070 views
Why do bit operators have such low precedence in C and C++?
In C and C++, the expression some_num & 0xABCD == 5 will effectively evaluate as some_num & (0xABCD == 5). This is unlike all of the standard arithmetic operators, as they have higher ...
Score of 4
1 answer
267 views
Why were charN_t designed as built-in types, but std::byte was not?
Why were char8_t, char16_t, char32_t designed as built-in types, but std::byte was not?
As per the C++ philosophy, if something can be implemented in the library, we almost always prefer doing so to ...
Score of 0
1 answer
199 views
Is there such a thing as a non-copiable type in Haskell?
In short, I'm trying to understand why copying, which is such a fundamental thing in C++ (fundamental in the sense that you, as the programmer, have quite a lot of power in writing code to permit or ...
Score of 33
2 answers
1761 views
What's the point of deleted virtual functions?
Apparently you can =delete virtual functions:
struct A
{
virtual void foo() = delete;
};
struct B : A
{
void foo() override = delete;
};
Interestingly, both functions have to be =deleted, or ...
Score of 5
1 answer
452 views
Is there really not cross product in std::linalg and if yes why?
I know for sure how to calculate a cross product myself, but usually I tree to use the standard library where possible.
I am aware that std::linalg is still in development so this might already be the ...
Score of 0
2 answers
296 views
Why ISO C++ forbid taking the address of a bound member function to form a pointer to member function?
Here is the error in GCC (which i have already fixed):
ISO C++ forbid taking the address of a bound member function to form a pointer to member function
This is the error line of my code:
threads[i] ...
Score of 0
2 answers
214 views
Why is the virtual keyword applied to methods instead of classes
When the virtual keyword is applied to a method the whole class becomes abstract.
Shouldn't the virtual or abstract keyword be applied to the class? It is a more intuitive design because it reflects ...
Score of 13
1 answer
537 views
Why doesn't the C++ standard implicitly define a lambda capturing nothing as `static` by default?
C++23 allows to define a lambda as static. i.e. If a lambda captures nothing, then it can be defined as static:
// with superfluous argument `this`, less efficient.
auto fn1 = [](int a, int b) { ...
Score of 4
1 answer
186 views
Why doesn't std::array's operator[] retain the value category of the array?
I'd have expected that if an std::array is an rvalue, then calling operator[] returns an rvalue as well. But it doesn't seem to be the case (cppreference), there are no value-category overloads.
For ...