Questions tagged [c++]
Programming questions are off-topic here. Do not ask questions about how to write code in C++. However, conceptual questions about computer science are more appropriate. See our help center for the scope of this site.
97 questions
9
votes
4
answers
8k
views
How does the linker know where to look for a function implementation in C++?
I am currently learning about how the compilation and linking works in C++. I think I kinda get how the compiler works, and that for a file to fully compile you don't need to have function ...
6
votes
1
answer
1k
views
How are extremely large integers stored and implemented in programming languages?
We have data types like int and long etc. which can store just a few bytes of integers.
But when we are implementing ...
6
votes
1
answer
939
views
Where are C++ templates inside of the lambda cube?
C++ templates have type variables and can express lambdas, so they must have System F embedded. But is that exactly where they are located in the lambda cube? Can C++ templates produce new types or ...
5
votes
4
answers
770
views
How do you find a hash function that respects a custom equality function?
I've been tasked with hashing arbitrary types in C++, with the caveat that A == B implies hash(A) == hash(B) even if equality of ...
5
votes
1
answer
482
views
Linked list: advantages of preventing movement of nodes and invalidating iterators on add/remove
C++ and Java include native classes for linked lists, C++ std::list and Java LinkedList
For C++ std::list, nodes can be "moved" within a list, or from list to list (if the lists are compatible), via ...
4
votes
1
answer
999
views
Why are struct and class essentially the same in C++?
struct and class in C++ are nearly identical (as covered for example here).
But why is this so? What did happen when C++ was ...
4
votes
0
answers
79
views
Subtype Check with Type DAG
Trying to understand how compiler/static-type-checker checks for subtyping, I run into 2 problems.
1. Reachability in DAG
Since both Python/C++ support multiple inheriatnce, the types can be ...
3
votes
1
answer
837
views
numerically stable log1pexp calculation
What are good approximations for computing log1pexp for single precision and double precision floating point numbers?
Note: ...
3
votes
1
answer
333
views
Why is the address-of operator in C/C++ represented with the "&" symbol?
I've started learning C++, and I know a little bit of C. Something that always struck me as somewhat off was that the address-of operator is represented with the seemingly random ampersand (&) ...
3
votes
4
answers
694
views
Is there an elegant algorithm for applying multiple simultaneous search-and-replace operations to a string?
The operation I'm interested in is a slight twist on your standard search-and-replace operation, in that instead of a single pair of arguments (replaceme and ...
3
votes
2
answers
128
views
Time complexity of a backtracking algorithm
I just solved the following Leetcode problem: All Paths From Source to Target
Here is my solution:
...
3
votes
1
answer
733
views
What type of function is main()?
As the functions are of 2 type:1.Pre-defined/library functions,2.User defined functions.
What type of function is main() function?
This doubt comes in my mind while writing a program we define the ...
3
votes
1
answer
3k
views
C++ STL: How does the distance() method work for a set/ multiset (stored internally as a self balancing tree)?
I'm working on the problem: Count smaller elements on right side using Set in C++ STL
The solution is to add each element to the set and then to count the elements on the left, the distance function ...
3
votes
0
answers
215
views
How to detect when to use radix sort in runtime
I'm implementing a stable integer sorting algorithm, I've chosen radix sort. I've tested LSD vs MSD implementation, wrote MSD/LSD hybrid implementation to reduce bandwidth pressure. The repo is here: ...
3
votes
0
answers
139
views
Summary of types of equivalence and equality in type theory, with notations and examples
Coming from non-computer science background, I am trying to understand the different types of equivalence and equality usually used in type theory. Ideally, I am looking for clear definitions and ...