3 ms·
It’s likely because std::fill() is a generic function that can be used to fill any list with any kind of value (even class instances). There likely is some tem
by EdSchouten 7y ago
It’s likely because std::fill() is a generic function that can be used to fill any list with any kind of value (even class instances).
There likely is some template specialization in place, that if it’s called with a ‘char’ list, that it gets translated into a call into libc’s memset(). That’s why the results for the last two are close to identical.
Alternatively, there is no template specialization going on, but it’s the case that the compiler detects that this is identical to memset() and converts it accordingly. LLVM/Clang does this through something called the LibCall optimization pass, IIRC.
- deleted 7y ago[deleted]