public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-apps@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH setup 3/9] Access StringOption's value by reference
Date: Tue, 06 Jun 2017 11:55:00 -0000	[thread overview]
Message-ID: <20170606115432.105020-4-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20170606115432.105020-1-jon.turney@dronecode.org.uk>

Access StringOption's value by reference, to avoid unnecessary temporaries.
---
 libgetopt++/include/getopt++/StringOption.h | 2 +-
 libgetopt++/src/StringOption.cc             | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libgetopt++/include/getopt++/StringOption.h b/libgetopt++/include/getopt++/StringOption.h
index f13bc22..f13be8c 100644
--- a/libgetopt++/include/getopt++/StringOption.h
+++ b/libgetopt++/include/getopt++/StringOption.h
@@ -32,7 +32,7 @@ public:
   virtual std::string const shortHelp () const;
   virtual Result Process (char const *);
   virtual Argument argument () const;
-  operator std::string () const;
+  operator const std::string& () const;
 
 private:
   Argument _optional;
diff --git a/libgetopt++/src/StringOption.cc b/libgetopt++/src/StringOption.cc
index 462cf0d..210b00a 100644
--- a/libgetopt++/src/StringOption.cc
+++ b/libgetopt++/src/StringOption.cc
@@ -60,7 +60,7 @@ StringOption::Process (char const *optarg)
   return Failed;
 }
 
-StringOption::operator string () const
+StringOption::operator const string& () const
 {
   return _value;
 }
-- 
2.12.3

  parent reply	other threads:[~2017-06-06 11:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-06 11:54 [PATCH setup 0/9] Setup patches Jon Turney
2017-06-06 11:54 ` [PATCH setup 4/9] Add Option::isPresent() method Jon Turney
2017-06-06 11:54 ` [PATCH setup 2/9] Alphabetically sort options in usage help Jon Turney
2017-06-06 11:55 ` [PATCH setup 6/9] Allow click-to-activate in PickView list control Jon Turney
2017-06-06 11:55 ` [PATCH setup 1/9] Allow options which only have long names Jon Turney
2017-06-06 11:55 ` Jon Turney [this message]
2017-06-06 11:55 ` [PATCH setup 7/9] Fix that clicking on any column changes "Keep" to "Uninstall" Jon Turney
2017-06-06 11:55 ` [PATCH setup 9/9] Avoid messagebox spam with file:// protocol URLs Jon Turney
2017-06-06 11:55 ` [PATCH setup 8/9] Fix useless error message Jon Turney
2017-06-06 11:55 ` [PATCH setup 5/9] Allow user-agent string to be customized Jon Turney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170606115432.105020-4-jon.turney@dronecode.org.uk \
    --to=jon.turney@dronecode.org.uk \
    --cc=cygwin-apps@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).