From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22137 invoked by alias); 15 May 2006 02:23:52 -0000 Received: (qmail 22119 invoked by uid 22791); 15 May 2006 02:23:50 -0000 X-Spam-Check-By: sourceware.org Received: from grunt8.ihug.co.nz (HELO grunt8.ihug.co.nz) (203.109.254.48) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 15 May 2006 02:23:46 +0000 Received: from 203-173-152-185.bliink.ihug.co.nz ([192.168.2.20]) [203.173.152.185] by grunt8.ihug.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1FfSkK-0007Rn-00; Mon, 15 May 2006 14:23:44 +1200 Message-ID: <4467E5FA.3020300@ecosm.com> Date: Mon, 15 May 2006 02:23:00 -0000 From: Will Bryant User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) MIME-Version: 1.0 To: pthreads-win32@sources.redhat.com Subject: Re: Using pthread_t as a key in a map References: <553911630605091355q64a6eec6i76cadef9b9efa0e@mail.gmail.com> In-Reply-To: <553911630605091355q64a6eec6i76cadef9b9efa0e@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact pthreads-win32-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sourceware.org X-SW-Source: 2006/txt/msg00019.txt.bz2 Hi Paolo, Bear in mind that pthreads-win32 is written in C, and operator overloading is a C++ feature, so adding that would prevent pthreads-win32 from compiling with C apps. One alternative is to make a custom comparator type and use that in the map declaration - or you could even simply move those operator overloads to your own units (they don't have to be defined where the type being compared is declared, as long as they've visible at the point where they're used - ie. your map declaration). But bear in mind that in any case, making use of the ptw32_handle_t type makes your code nonportable, and since portability is generally the reason one is using pthreads-win32 in the first place, this is perhaps not the best design for general use. Will Paolo Brandoli wrote: > I have a source code that uses the pthread_t as a key in a std::map. > Because pthread-win32 defines pthread_t as a structure, the > compilation fails. > > I added the following lines in my pthread.h header in order to allow > the usage of pthread_t in the map: > > bool operator < (const ptw32_handle_t& left, const ptw32_handle_t& right) > { > return left.p < right.p; > } > > bool operator > (const ptw32_handle_t& left, const ptw32_handle_t& right) > { > return left.p > right.p; > } > > Bye > Paolo Brandoli > http://www.puntoexe.com > -- Will Bryant