From patchwork Mon Jan 26 11:19:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 432724 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 468D214019D for ; Mon, 26 Jan 2015 22:19:37 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:content-transfer-encoding:in-reply-to; q=dns; s= default; b=rKhhrXY4NqiTy+j8pCuU3+OfH/v1CTb7wKe+UMvA88l+gHBXommia bi80rW9Dt7cqInOWkgO2jZCZ0pOw+8p22nSe62yC564qjDM/dW6kGqJOFLRZayUQ w+KoYoY/idCbJBCA9cuEIB/a6HyJ097gDRzYQbRNdwJoKCDF2D4CpE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:content-transfer-encoding:in-reply-to; s=default; bh=gW/1sCO6iqnxupBnzcv3vD6B3Yg=; b=x60m3FM19UrO4w1aukC3ZrFqQEKh k6qDrkq41+l5wIyQXzUovdQL+oo3hwnnrK4sZvUex3mHawvx/uWNZLd53T2ugE7R LVg/H5p9YlNkrxycCLNaWdm/rhg9CsdQCSdFaaU6c4dfqfzOtnHwvsGZv8vC03oS GzdTIiyFm683A8Q= Received: (qmail 4453 invoked by alias); 26 Jan 2015 11:19:17 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 905 invoked by uid 89); 26 Jan 2015 11:19:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 26 Jan 2015 11:19:06 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0QBJ5jl003124 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Jan 2015 06:19:05 -0500 Received: from localhost (ovpn-116-136.ams2.redhat.com [10.36.116.136]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0QBJ4RN014759; Mon, 26 Jan 2015 06:19:04 -0500 Date: Mon, 26 Jan 2015 11:19:04 +0000 From: Jonathan Wakely To: =?iso-8859-1?Q?Fran=E7ois?= Dumont Cc: libstdc++@gcc.gnu.org, gcc-patches Subject: Re: [patch] [C++14] Implement N3657: heterogeneous lookup in associative containers. Message-ID: <20150126111903.GX3360@redhat.com> References: <20150119171608.GM3360@redhat.com> <20150120120015.GU3360@redhat.com> <54C0287C.5020502@gmail.com> <20150122020727.GJ3360@redhat.com> <54C416CD.4010907@gmail.com> <20150124224653.GT3360@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150124224653.GT3360@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) On 24/01/15 22:46 +0000, Jonathan Wakely wrote: >On 24/01/15 23:03 +0100, François Dumont wrote: >>types. I am also surprised that it is not using enable_if, IMHO it >>makes the code clearer. > >It doesn't work though. > >>@@ -1155,9 +1150,8 @@ >> return _S_iter(__y); >> } >> >>- template>- typename _Req = typename __is_transparent<_Compare, _Kt>::type> >>- iterator >>+ template >>+ enable_if_t<__has_is_transparent<_Compare>::value, iterator> >> _M_find_tr(const _Kt& __k) > >This doesn't work. > >Consider: > > #include > > struct I > { > int i; > operator int() const { return i; } > }; > > int main() > { > std::set s; > I i = { }; > s.find(i); > } > >(I will add something like this to the testsuite.) Done with this patch, tested x86_64-linux and committed to trunk. commit ba331e783334feb20f30f1b92a93d8c9d8f895be Author: Jonathan Wakely Date: Mon Jan 26 10:43:16 2015 +0000 * testsuite/23_containers/set/operations/2.cc: Add test for non-transparent comparison function. diff --git a/libstdc++-v3/testsuite/23_containers/set/operations/2.cc b/libstdc++-v3/testsuite/23_containers/set/operations/2.cc index 752bc7d..84ddd1f 100644 --- a/libstdc++-v3/testsuite/23_containers/set/operations/2.cc +++ b/libstdc++-v3/testsuite/23_containers/set/operations/2.cc @@ -128,6 +128,22 @@ test05() VERIFY( Cmp::count == 0); } +void +test06() +{ + // https://gcc.gnu.org/ml/libstdc++/2015-01/msg00176.html + // Verify the new function template overloads do not cause problems + // when the comparison function is not transparent. + struct I + { + int i; + operator int() const { return i; } + }; + + std::set s; + I i = { }; + s.find(i); +} int main() @@ -137,4 +153,5 @@ main() test03(); test04(); test05(); + test06(); }