🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2252

Re: Determining between classes and built-in t

#2252
From: J. Kanze
Date: Thu, 19 Oct 1995 10:46
34 lines
2428 bytes
Cay S. Horstmann (horstman@jupiter.SJSU.EDU) wrote:

|> I did have this problem [determining whether a type is built-in or
|> not] when trying to write a decent array template.
|> For numeric and pointer types, I'd like to use memmove when the array
|> grows and is relocated. For class types that cannot be done in
|> general. I did "solve" the problem by having two templates, but now
|> the risk is that someone who doesn't understand the distinction uses
|> the "BuiltinTypeArray" (not its real name) with a class type, which
|> might have bizarre results. So I think Brett's desire is not totally
|> outlandish.  

At least for your problem, I would just write the loop and forget it.

On a RISC machine, it is probably that the generated code will be
superior to using memmove, since the compiler, knowing the actual types,
can make suppositions concerning the alignment that memmove cannot.
This is also true for 68000's.

On an 80x86: the compiler will recognize the loop and generate the
optimal movs instruction in its place.  (Warning: I've not verified this
personally, but Microsoft was claiming this in adds at least 10 years
ago, so I would imagine that all compilers do it today.)  At least one
NSC 32000 compiler I used would do this too.

-- 
James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils en informatique industrielle--
                             --Beratung in industrieller Datenverarbeitung
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <46594d$5b9@gabi.gabi-soft.fr>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <Pine.SGI.3.91.951003143924.20596A-100000@gusak> <450v2o$f3g@engnews2.Eng.Sun.COM> <45mor5$fms@jupiter.SJSU.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 19 Oct 95 10:46:30 GMT
Approved: fjh@cs.mu.oz.au
From: kanze@gabi-soft.fr (J. Kanze)
Newsgroups: comp.std.c++
Subject: Re: Determining between classes and built-in t
X-Original-Date: 19 Oct 1995 11:26:21 +0100
Organization: GABI Software, Sarl.
Message-ID: <46594d$5b9@gabi.gabi-soft.fr>
References: <Pine.SGI.3.91.951003143924.20596A-100000@gusak> <450v2o$f3g@engnews2.Eng.Sun.COM> <45mor5$fms@jupiter.SJSU.EDU>
X-Newsreader: TIN [version 1.2 PL2]
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMIYsjuEDnX0m9pzZAQHNHAF+LzmR/3Uv4085pb+896qjH85jlojuDdGR
 e66ntMWWsH+eWK3PTvFrWWcAl/v06A3a
 =/olH