map with incomplete value type

The standard requires that, all types used in template components of the standard library must be complete, unless otherwise stated. Thus libc++’s error is correct. Using an incomplete type is undefined behavior (§17.6.4.8[res.on.functions]/2), so libstdc++ accepting it isn’t wrong either. You could use a pointer object to construct the complete type as you did. But … Read more

Linux function to get mount points

Please see the clarification at the bottom of the answer for the reasoning being used in this answer. Is there any reason that you would not use the getmntent libc library call? I do realize that it’s not the same as an ‘all in one’ system call, but it should allow you to get the … Read more

How to link to a different libc file?

I found out how to do it: rpath specifies where the provided libraries are located. This folder should contain: libc.so.6, libdl.so.2, libgcc_s.so.1 and maybe more. Check with strace to find out which libraries your binary file uses. ld.so is the provided linker gcc -Xlinker -rpath=/default/path/to/libraries -Xlinker -I/default/path/to/libraries/ld.so program.c

Why the libc++ std::vector internally keeps three pointers instead of one pointer and two sizes?

It’s because the rationale is that performance should be optimized for iterators, not indices. (In other words, performance should be optimized for begin()/end(), not size()/operator[].) Why? Because iterators are generalized pointers, and thus C++ encourages their use, and in return ensures that their performance matches those of raw pointers when the two are equivalent. To … Read more