🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.help
Article #739

Re: g++ and qsort

#739
From: Charles Fiterman
Date: Wed, 23 Aug 1995 13:39
8 lines
885 bytes
Qsort assumes that objects can me moved bitwise. Many C++ objects have interior
pointers and cannot be moved bitwise. They must be copied and deleted in place.

Therefore what you should do is build an array of pointers to the objects and
sort the array. References to the sorted array should use the pointers. 

The alternative is to write a C++ template qsort that uses a temporary object
for exchange. This would be much slower.
Technical Details
Message-ID: <DDrnAF.E76@midway.uchicago.edu>
Path: arc1-ca.pugleaf.net!vixen.cso.uiuc.edu!uchinews!news
References: <DDpG3H.88M@watserv3.uwaterloo.ca> <DDqM06.52K@pentagon-ai.army.mil>

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.help,comp.lang.c++
Path: arc1-ca.pugleaf.net!vixen.cso.uiuc.edu!uchinews!news
From: Charles Fiterman <cef@geodesic.com>
Subject: Re: g++ and qsort
X-Nntp-Posting-Host: ford.uchicago.edu
Message-ID: <DDrnAF.E76@midway.uchicago.edu>
Sender: news@midway.uchicago.edu (News Administrator)
Organization: Geodesic Systems
References: <DDpG3H.88M@watserv3.uwaterloo.ca> <DDqM06.52K@pentagon-ai.army.mil>
Date: Wed, 23 Aug 1995 13:39:50 GMT