diff --git a/include/tclap/MultiArg.h b/include/tclap/MultiArg.h index 34bb2d7..28fd7cc 100644 --- a/include/tclap/MultiArg.h +++ b/include/tclap/MultiArg.h @@ -185,7 +185,7 @@ public: * Returns a vector of type T containing the values parsed from * the command line. */ - const std::vector& getValue(); + const std::vector& getValue() const { return _values; } /** * Returns an iterator over the values parsed from the command @@ -301,9 +301,6 @@ MultiArg::MultiArg(const std::string& flag, _acceptsMultipleValues = true; } -template -const std::vector& MultiArg::getValue() { return _values; } - template bool MultiArg::processArg(int *i, std::vector& args) { diff --git a/include/tclap/MultiSwitchArg.h b/include/tclap/MultiSwitchArg.h index 8820b64..2bd80bf 100644 --- a/include/tclap/MultiSwitchArg.h +++ b/include/tclap/MultiSwitchArg.h @@ -108,7 +108,7 @@ class MultiSwitchArg : public SwitchArg /** * Returns int, the number of times the switch has been set. */ - int getValue(); + int getValue() const { return _value; } /** * Returns the shortID for this Arg. @@ -150,8 +150,6 @@ _default( init ) parser.add( this ); } -inline int MultiSwitchArg::getValue() { return _value; } - inline bool MultiSwitchArg::processArg(int *i, std::vector& args) { if ( _ignoreable && Arg::ignoreRest() ) diff --git a/include/tclap/SwitchArg.h b/include/tclap/SwitchArg.h index 51a8944..b3e5ce7 100644 --- a/include/tclap/SwitchArg.h +++ b/include/tclap/SwitchArg.h @@ -111,7 +111,7 @@ public: /** * Returns bool, whether or not the switch has been set. */ - bool getValue() /* TODO(macbishop) should be const */; + bool getValue() const { return _value; } /** * A SwitchArg can be used as a boolean, indicating @@ -161,8 +161,6 @@ inline SwitchArg::SwitchArg(const std::string& flag, parser.add( this ); } -inline bool SwitchArg::getValue() { return _value; } - inline bool SwitchArg::lastCombined(std::string& combinedSwitches ) { for ( unsigned int i = 1; i < combinedSwitches.length(); i++ ) diff --git a/include/tclap/ValueArg.h b/include/tclap/ValueArg.h index d52d50e..7b1752b 100644 --- a/include/tclap/ValueArg.h +++ b/include/tclap/ValueArg.h @@ -220,13 +220,17 @@ public: /** * Returns the value of the argument. */ - /* const */ T& getValue() /* TODO(macbishop): should be const */; + const T& getValue() const { return _value; } + + // TODO(macbishop): Non-const variant is deprecated, don't + // use. Remove in next major. + T& getValue() { return _value; } /** * A ValueArg can be used as as its value type (T) This is the * same as calling getValue() */ - operator const T&() const { return _value; } + operator const T&() const { return getValue(); } /** * Specialization of shortID. @@ -321,13 +325,6 @@ ValueArg::ValueArg(const std::string& flag, parser.add( this ); } - -/** - * Implementation of getValue(). - */ -template -T& ValueArg::getValue() { return _value; } - /** * Implementation of processArg(). */