From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 90396 invoked by alias); 20 Oct 2016 03:17:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 90287 invoked by uid 89); 20 Oct 2016 03:17:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.2 required=5.0 tests=AWL,BAYES_50,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=H*r:112, object_file, **object_file, source_file X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Oct 2016 03:17:09 +0000 Received: by simark.ca (Postfix, from userid 112) id C87211E486; Wed, 19 Oct 2016 23:17:07 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id CFF671E124; Wed, 19 Oct 2016 23:17:06 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 20 Oct 2016 03:17:00 -0000 From: Simon Marchi To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v2 21/31] Use ui_file_as_string in gdb/compile/ In-Reply-To: <7a6e4bde-9ca2-4163-bdd7-0fd1f88a516b@redhat.com> References: <1476839539-8374-1-git-send-email-palves@redhat.com> <1476839539-8374-22-git-send-email-palves@redhat.com> <8a267925d9af7f5b01c75a81da15b664@simark.ca> <7a6e4bde-9ca2-4163-bdd7-0fd1f88a516b@redhat.com> Message-ID: <616c3e9e394bd7b449cce98204fc2c50@simark.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.2.0 X-IsSubscribed: yes X-SW-Source: 2016-10/txt/msg00596.txt.bz2 On 2016-10-19 19:48, Pedro Alves wrote: > Well, there's std::pair in C++03, and std::tuple in C++11. > And C++17 has structured bindings: > > auto [source_file, object_file] = compile_to_object (); > > :-) > > But I think returning a real named struct is clearer than all that. > See patch below showing the idea. WDYT? Well, your last example looks really nice, since it avoids the overhead of writing a class just for one return value, but since we don't have access to C++17 quite yet, a class will have to do. >> >> Btw, would it be good to use references for those strings? > > Maybe. I had kept it using pointers to make it clearer at the > call site that these are output parameters. Maybe that's > old-school C++ mentality? That moot with this version of the > patch though, so I can dodge discussing that for now. :-) I understand, I don't know which one is best. What's nice with references is that you can't call it with something wrong. The patch looks good to me... just one missing space... > -static void > -get_new_file_names (char **source_file, char **object_file) > +class compile_file_names > +{ > +public: > + compile_file_names(std::string source_file, std::string object_file) ...here?