Skip to main content
Filter by
Sorted by
Tagged with
6 votes
1 answer
193 views

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 ...
Chris_F's user avatar
  • 5,825
58 votes
1 answer
5k views

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 ...
bhfelliot's user avatar
  • 667
0 votes
1 answer
156 views

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 ...
Enlico's user avatar
  • 30.2k
5 votes
1 answer
303 views

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 ...
Torsten Knodt's user avatar
0 votes
2 answers
188 views

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 ...
rishflab 's user avatar
4 votes
1 answer
169 views

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 ...
geza's user avatar
  • 30.5k
1 vote
1 answer
138 views

I'm the creator of https://github.com/nevalang/neva It's a dataflow programming where you have nodes that do message passing through ports. I use go channels to implement that. However, I faced an ...
emil14's user avatar
  • 81
4 votes
1 answer
163 views

I was perplexed to see that the template parameter requirement for std::distance is a LegacyInputIterator rather than a LegacyForwardIterator. Since input-only iterators don't have the multi-pass ...
Spencer's user avatar
  • 2,254
3 votes
0 answers
47 views

I was going through this guide on operator overloading in C++. If I try to implement all the comparison operators using the <=> operator: friend auto operator<=>(const Some_class& lhs, ...
a_floating_point's user avatar
6 votes
1 answer
941 views

I start experiment with std::string_view. It has a very ugly feature. You cannot say: std::string_view<const char> and std::string_view<char> like the awesome std::span. So, you cannot ...
Chameleon's user avatar
  • 2,239
3 votes
1 answer
95 views

int x = f(); inline int y = x; It is unspecified whether y is zero or the value of x. Note that x has ordered initialization and y has partially-ordered initialization (see [basic.start.dynamic] p1). ...
Jan Schultke's user avatar
  • 43.6k
0 votes
2 answers
147 views

From there I know that it is illegal in C to call offsetof on a pointer, but why is it undefined behaviour? Standard implementation #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)...
user avatar
0 votes
1 answer
71 views

Say we have this assignment statement: a = 5 Even though it'd obviously be ugly to do this for no reason, we could technically accomplish the same thing with: (a := 5) This still assigns 5 to a, and ...
Inertial Ignorance's user avatar
0 votes
0 answers
45 views

I have created a front-end for my language. I have also been able to transpile to C so that it can be compiled. In this language, functions are treated as first-class objects. Is it possible to ...
jinTgreater's user avatar
1 vote
2 answers
167 views

As https://without.boats/blog/why-async-rust/ puts it, OS threads have a large pre-allocated stack, which increases per-thread memory overhead. And the article goes on to argue that much of the ...
rwallace's user avatar
  • 34.1k
2 votes
1 answer
96 views

I'm writing a programming language (details irrelevant) which uses Lisp-like cons cells to store its data (this makes implementing the garbage collector easy). I'll spare you the details of everything ...
dragoncoder047's user avatar
24 votes
2 answers
3k views

In Rust, asynchronous functions do not require allocating on the heap. Function async returns a compiler-generated structure on which you call a compiler generated poll method. The design of async ...
VadimP22's user avatar
  • 365
-1 votes
2 answers
109 views

I am still pretty new to c++ and would like to understand the thought process behind creating member variables the way it is. For example, if I go through a header file, I see some of the member ...
mahacoder's user avatar
  • 923
0 votes
1 answer
115 views

I have been followings this article which explains nan boxing https://piotrduperas.com/posts/nan-boxing and tried to implement it in my own "language". typedef union { uint64_t as_uint; ...
yan3ku's user avatar
  • 3
1 vote
1 answer
70 views

Suppose I was writing a linear algebra library in C#, and I wanted to implement matrix multiplication. Of course, two matrices A and B can only be multiplied to form AB if A has as many columns as B ...
ummg's user avatar
  • 291
0 votes
0 answers
72 views

iterator_traits is specialized for pointers as namespace std { template<class T> requires is_object_v<T> struct iterator_traits<T*> { using iterator_concept = ...
Jan Schultke's user avatar
  • 43.6k
22 votes
3 answers
3k views

The legacy std::for_each returns function as the standard only requires Function to meet Cpp17MoveConstructible according to [alg.foreach]: template<class InputIterator, class Function> ...
康桓瑋's user avatar
  • 46.8k
1 vote
1 answer
85 views

This is a question about understanding a design decision, not a complaint about bugs or flaws. In the C++ standard library, the function to create a shared pointer and its object is a straight ...
Peter Fletcher's user avatar
0 votes
1 answer
85 views

I am writing a small scripting language for a project I am working on. I wrote a simple recursive-descent parser for it (similar to the one in the Crafting Interpreters). I wanted to add support for ...
Abdelfattah Radwan's user avatar
0 votes
0 answers
227 views

In my main function, I have allocated an i8 pointer: %a = alloca i8*, align 8 store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @1, i32 0, i32 0), i8** %a, align 8 Is it possible to: assign a ...
Kellan_B's user avatar

1
2 3 4 5
30