James Kanze
11/21/2008 9:58:00 AM
On Nov 20, 2:03 pm, Jeff Schwab <j...@schwabcenter.com> wrote:
> James Kanze wrote:
> > On Nov 19, 8:26 pm, Jeff Schwab <j...@schwabcenter.com> wrote:
> >> I wonder whether popular implementations of std::copy delegate
> >> to memcpy for types with trivial copy constructors.
> > They may or they may not. With a good compiler, generating
> > the code directly inline probably results in faster code,
> > and maybe even smaller code.
> That raises another interesting question: Are there any
> platforms that define both their C and C++ standard libraries
> on top of a shared subset, rather than just providing C++
> aliases for old C?
There are probably some, but in many cases, the C library is
bundled with the system.
> For example, are there any implementations that just forward
> both memcpy and (sometimes) std::copy to an internal
> __inline_memcpy?
I always thought that the usual implementation of memcpy in the
C header was something like:
extern void* memcpy( void* dest, void const* src, size_t n ) ;
#define memcpy( dest, src, n ) __builtin_memcpy( dest, src, n )
(But of course, this causes problems when the library is bundled
as well.) And of course, since it is a template, the compiler
can already see all of the code for std::copy, and optimize
accordingly.
Of course, this is only valid for simple functions like memcpy.
I can't imagine any implementation using a compiler builtin for
something like strftime.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34