Commit 12bc8d78e778b65bec357760bbe26b734abdf0e7

Authored by Rosen Penev
Committed by GitHub
1 parent b0f67a06

clang-tidy fixes (#231)

Showing 1 changed file with 108 additions and 129 deletions
include/cxxopts.hpp
... ... @@ -25,8 +25,8 @@ THE SOFTWARE.
25 25 #ifndef CXXOPTS_HPP_INCLUDED
26 26 #define CXXOPTS_HPP_INCLUDED
27 27  
28   -#include <cstring>
29 28 #include <cctype>
  29 +#include <cstring>
30 30 #include <exception>
31 31 #include <iostream>
32 32 #include <limits>
... ... @@ -37,6 +37,7 @@ THE SOFTWARE.
37 37 #include <string>
38 38 #include <unordered_map>
39 39 #include <unordered_set>
  40 +#include <utility>
40 41 #include <vector>
41 42  
42 43 #ifdef __cpp_lib_optional
... ... @@ -61,7 +62,7 @@ namespace cxxopts
61 62 CXXOPTS__VERSION_MINOR,
62 63 CXXOPTS__VERSION_PATCH
63 64 };
64   -}
  65 +} // namespace cxxopts
65 66  
66 67 //when we ask cxxopts to use Unicode, help strings are processed using ICU,
67 68 //which results in the correct lengths being computed for strings when they
... ... @@ -227,9 +228,9 @@ namespace cxxopts
227 228  
228 229 inline
229 230 String&
230   - stringAppend(String&s, String a)
  231 + stringAppend(String&s, const String& a)
231 232 {
232   - return s.append(std::move(a));
  233 + return s.append(a);
233 234 }
234 235  
235 236 inline
... ... @@ -259,7 +260,7 @@ namespace cxxopts
259 260 {
260 261 return s.empty();
261 262 }
262   -}
  263 +} // namespace cxxopts
263 264  
264 265 //ifdef CXXOPTS_USE_UNICODE
265 266 #endif
... ... @@ -275,7 +276,7 @@ namespace cxxopts
275 276 const std::string LQUOTE("‘");
276 277 const std::string RQUOTE("’");
277 278 #endif
278   - }
  279 + } // namespace
279 280  
280 281 class Value : public std::enable_shared_from_this<Value>
281 282 {
... ... @@ -324,13 +325,13 @@ namespace cxxopts
324 325 class OptionException : public std::exception
325 326 {
326 327 public:
327   - OptionException(const std::string& message)
328   - : m_message(message)
  328 + explicit OptionException(std::string message)
  329 + : m_message(std::move(message))
329 330 {
330 331 }
331 332  
332   - virtual const char*
333   - what() const noexcept
  333 + const char*
  334 + what() const noexcept override
334 335 {
335 336 return m_message.c_str();
336 337 }
... ... @@ -343,7 +344,7 @@ namespace cxxopts
343 344 {
344 345 public:
345 346  
346   - OptionSpecException(const std::string& message)
  347 + explicit OptionSpecException(const std::string& message)
347 348 : OptionException(message)
348 349 {
349 350 }
... ... @@ -352,7 +353,7 @@ namespace cxxopts
352 353 class OptionParseException : public OptionException
353 354 {
354 355 public:
355   - OptionParseException(const std::string& message)
  356 + explicit OptionParseException(const std::string& message)
356 357 : OptionException(message)
357 358 {
358 359 }
... ... @@ -361,7 +362,7 @@ namespace cxxopts
361 362 class option_exists_error : public OptionSpecException
362 363 {
363 364 public:
364   - option_exists_error(const std::string& option)
  365 + explicit option_exists_error(const std::string& option)
365 366 : OptionSpecException("Option " + LQUOTE + option + RQUOTE + " already exists")
366 367 {
367 368 }
... ... @@ -370,7 +371,7 @@ namespace cxxopts
370 371 class invalid_option_format_error : public OptionSpecException
371 372 {
372 373 public:
373   - invalid_option_format_error(const std::string& format)
  374 + explicit invalid_option_format_error(const std::string& format)
374 375 : OptionSpecException("Invalid option format " + LQUOTE + format + RQUOTE)
375 376 {
376 377 }
... ... @@ -378,7 +379,7 @@ namespace cxxopts
378 379  
379 380 class option_syntax_exception : public OptionParseException {
380 381 public:
381   - option_syntax_exception(const std::string& text)
  382 + explicit option_syntax_exception(const std::string& text)
382 383 : OptionParseException("Argument " + LQUOTE + text + RQUOTE +
383 384 " starts with a - but has incorrect syntax")
384 385 {
... ... @@ -388,7 +389,7 @@ namespace cxxopts
388 389 class option_not_exists_exception : public OptionParseException
389 390 {
390 391 public:
391   - option_not_exists_exception(const std::string& option)
  392 + explicit option_not_exists_exception(const std::string& option)
392 393 : OptionParseException("Option " + LQUOTE + option + RQUOTE + " does not exist")
393 394 {
394 395 }
... ... @@ -397,7 +398,7 @@ namespace cxxopts
397 398 class missing_argument_exception : public OptionParseException
398 399 {
399 400 public:
400   - missing_argument_exception(const std::string& option)
  401 + explicit missing_argument_exception(const std::string& option)
401 402 : OptionParseException(
402 403 "Option " + LQUOTE + option + RQUOTE + " is missing an argument"
403 404 )
... ... @@ -408,7 +409,7 @@ namespace cxxopts
408 409 class option_requires_argument_exception : public OptionParseException
409 410 {
410 411 public:
411   - option_requires_argument_exception(const std::string& option)
  412 + explicit option_requires_argument_exception(const std::string& option)
412 413 : OptionParseException(
413 414 "Option " + LQUOTE + option + RQUOTE + " requires an argument"
414 415 )
... ... @@ -436,7 +437,7 @@ namespace cxxopts
436 437 class option_not_present_exception : public OptionParseException
437 438 {
438 439 public:
439   - option_not_present_exception(const std::string& option)
  440 + explicit option_not_present_exception(const std::string& option)
440 441 : OptionParseException("Option " + LQUOTE + option + RQUOTE + " not present")
441 442 {
442 443 }
... ... @@ -445,7 +446,7 @@ namespace cxxopts
445 446 class argument_incorrect_type : public OptionParseException
446 447 {
447 448 public:
448   - argument_incorrect_type
  449 + explicit argument_incorrect_type
449 450 (
450 451 const std::string& arg
451 452 )
... ... @@ -459,7 +460,7 @@ namespace cxxopts
459 460 class option_required_exception : public OptionParseException
460 461 {
461 462 public:
462   - option_required_exception(const std::string& option)
  463 + explicit option_required_exception(const std::string& option)
463 464 : OptionParseException(
464 465 "Option " + LQUOTE + option + RQUOTE + " is required but not present"
465 466 )
... ... @@ -497,7 +498,7 @@ namespace cxxopts
497 498 ("(t|T)(rue)?|1");
498 499 std::basic_regex<char> falsy_pattern
499 500 ("(f|F)(alse)?|0");
500   - }
  501 + } // namespace
501 502  
502 503 namespace detail
503 504 {
... ... @@ -542,7 +543,7 @@ namespace cxxopts
542 543 {
543 544 SignedCheck<T, std::numeric_limits<T>::is_signed>()(negative, value, text);
544 545 }
545   - }
  546 + } // namespace detail
546 547  
547 548 template <typename R, typename T>
548 549 R
... ... @@ -745,7 +746,7 @@ namespace cxxopts
745 746 {
746 747 std::stringstream in(text);
747 748 std::string token;
748   - while(in.eof() == false && std::getline(in, token, CXXOPTS_VECTOR_DELIMITER)) {
  749 + while(!in.eof() && std::getline(in, token, CXXOPTS_VECTOR_DELIMITER)) {
749 750 T v;
750 751 parse_value(token, v);
751 752 value.emplace_back(std::move(v));
... ... @@ -798,12 +799,12 @@ namespace cxxopts
798 799 {
799 800 }
800 801  
801   - abstract_value(T* t)
  802 + explicit abstract_value(T* t)
802 803 : m_store(t)
803 804 {
804 805 }
805 806  
806   - virtual ~abstract_value() = default;
  807 + ~abstract_value() override = default;
807 808  
808 809 abstract_value(const abstract_value& rhs)
809 810 {
... ... @@ -824,37 +825,37 @@ namespace cxxopts
824 825 }
825 826  
826 827 void
827   - parse(const std::string& text) const
  828 + parse(const std::string& text) const override
828 829 {
829 830 parse_value(text, *m_store);
830 831 }
831 832  
832 833 bool
833   - is_container() const
  834 + is_container() const override
834 835 {
835 836 return type_is_container<T>::value;
836 837 }
837 838  
838 839 void
839   - parse() const
  840 + parse() const override
840 841 {
841 842 parse_value(m_default_value, *m_store);
842 843 }
843 844  
844 845 bool
845   - has_default() const
  846 + has_default() const override
846 847 {
847 848 return m_default;
848 849 }
849 850  
850 851 bool
851   - has_implicit() const
  852 + has_implicit() const override
852 853 {
853 854 return m_implicit;
854 855 }
855 856  
856 857 std::shared_ptr<Value>
857   - default_value(const std::string& value)
  858 + default_value(const std::string& value) override
858 859 {
859 860 m_default = true;
860 861 m_default_value = value;
... ... @@ -862,7 +863,7 @@ namespace cxxopts
862 863 }
863 864  
864 865 std::shared_ptr<Value>
865   - implicit_value(const std::string& value)
  866 + implicit_value(const std::string& value) override
866 867 {
867 868 m_implicit = true;
868 869 m_implicit_value = value;
... ... @@ -870,26 +871,26 @@ namespace cxxopts
870 871 }
871 872  
872 873 std::shared_ptr<Value>
873   - no_implicit_value()
  874 + no_implicit_value() override
874 875 {
875 876 m_implicit = false;
876 877 return shared_from_this();
877 878 }
878 879  
879 880 std::string
880   - get_default_value() const
  881 + get_default_value() const override
881 882 {
882 883 return m_default_value;
883 884 }
884 885  
885 886 std::string
886   - get_implicit_value() const
  887 + get_implicit_value() const override
887 888 {
888 889 return m_implicit_value;
889 890 }
890 891  
891 892 bool
892   - is_boolean() const
  893 + is_boolean() const override
893 894 {
894 895 return std::is_same<T, bool>::value;
895 896 }
... ... @@ -901,10 +902,7 @@ namespace cxxopts
901 902 {
902 903 return *m_result;
903 904 }
904   - else
905   - {
906   - return *m_store;
907   - }
  905 + return *m_store;
908 906 }
909 907  
910 908 protected:
... ... @@ -935,21 +933,21 @@ namespace cxxopts
935 933 class standard_value<bool> : public abstract_value<bool>
936 934 {
937 935 public:
938   - ~standard_value() = default;
  936 + ~standard_value() override = default;
939 937  
940 938 standard_value()
941 939 {
942 940 set_default_and_implicit();
943 941 }
944 942  
945   - standard_value(bool* b)
  943 + explicit standard_value(bool* b)
946 944 : abstract_value(b)
947 945 {
948 946 set_default_and_implicit();
949 947 }
950 948  
951 949 std::shared_ptr<Value>
952   - clone() const
  950 + clone() const override
953 951 {
954 952 return std::make_shared<standard_value<bool>>(*this);
955 953 }
... ... @@ -965,7 +963,7 @@ namespace cxxopts
965 963 m_implicit_value = "true";
966 964 }
967 965 };
968   - }
  966 + } // namespace values
969 967  
970 968 template <typename T>
971 969 std::shared_ptr<Value>
... ... @@ -988,15 +986,15 @@ namespace cxxopts
988 986 public:
989 987 OptionDetails
990 988 (
991   - const std::string& short_,
992   - const std::string& long_,
993   - const String& desc,
  989 + std::string short_,
  990 + std::string long_,
  991 + String desc,
994 992 std::shared_ptr<const Value> val
995 993 )
996   - : m_short(short_)
997   - , m_long(long_)
998   - , m_desc(desc)
999   - , m_value(val)
  994 + : m_short(std::move(short_))
  995 + , m_long(std::move(long_))
  996 + , m_desc(std::move(desc))
  997 + , m_value(std::move(val))
1000 998 , m_count(0)
1001 999 {
1002 1000 }
... ... @@ -1073,7 +1071,7 @@ namespace cxxopts
1073 1071 void
1074 1072 parse
1075 1073 (
1076   - std::shared_ptr<const OptionDetails> details,
  1074 + const std::shared_ptr<const OptionDetails>& details,
1077 1075 const std::string& text
1078 1076 )
1079 1077 {
... ... @@ -1083,7 +1081,7 @@ namespace cxxopts
1083 1081 }
1084 1082  
1085 1083 void
1086   - parse_default(std::shared_ptr<const OptionDetails> details)
  1084 + parse_default(const std::shared_ptr<const OptionDetails>& details)
1087 1085 {
1088 1086 ensure_value(details);
1089 1087 m_default = true;
... ... @@ -1120,7 +1118,7 @@ namespace cxxopts
1120 1118  
1121 1119 private:
1122 1120 void
1123   - ensure_value(std::shared_ptr<const OptionDetails> details)
  1121 + ensure_value(const std::shared_ptr<const OptionDetails>& details)
1124 1122 {
1125 1123 if (m_value == nullptr)
1126 1124 {
... ... @@ -1175,7 +1173,7 @@ namespace cxxopts
1175 1173 public:
1176 1174  
1177 1175 ParseResult(
1178   - const std::shared_ptr<
  1176 + std::shared_ptr<
1179 1177 std::unordered_map<std::string, std::shared_ptr<OptionDetails>>
1180 1178 >,
1181 1179 std::vector<std::string>,
... ... @@ -1226,18 +1224,18 @@ namespace cxxopts
1226 1224 add_to_option(const std::string& option, const std::string& arg);
1227 1225  
1228 1226 bool
1229   - consume_positional(std::string a);
  1227 + consume_positional(const std::string& a);
1230 1228  
1231 1229 void
1232 1230 parse_option
1233 1231 (
1234   - std::shared_ptr<OptionDetails> value,
  1232 + const std::shared_ptr<OptionDetails>& value,
1235 1233 const std::string& name,
1236 1234 const std::string& arg = ""
1237 1235 );
1238 1236  
1239 1237 void
1240   - parse_default(std::shared_ptr<OptionDetails> details);
  1238 + parse_default(const std::shared_ptr<OptionDetails>& details);
1241 1239  
1242 1240 void
1243 1241 checked_parse_arg
... ... @@ -1245,7 +1243,7 @@ namespace cxxopts
1245 1243 int argc,
1246 1244 char* argv[],
1247 1245 int& current,
1248   - std::shared_ptr<OptionDetails> value,
  1246 + const std::shared_ptr<OptionDetails>& value,
1249 1247 const std::string& name
1250 1248 );
1251 1249  
... ... @@ -1266,15 +1264,15 @@ namespace cxxopts
1266 1264 {
1267 1265 Option
1268 1266 (
1269   - const std::string& opts,
1270   - const std::string& desc,
1271   - const std::shared_ptr<const Value>& value = ::cxxopts::value<bool>(),
1272   - const std::string& arg_help = ""
  1267 + std::string opts,
  1268 + std::string desc,
  1269 + std::shared_ptr<const Value> value = ::cxxopts::value<bool>(),
  1270 + std::string arg_help = ""
1273 1271 )
1274   - : opts_(opts)
1275   - , desc_(desc)
1276   - , value_(value)
1277   - , arg_help_(arg_help)
  1272 + : opts_(std::move(opts))
  1273 + , desc_(std::move(desc))
  1274 + , value_(std::move(value))
  1275 + , arg_help_(std::move(arg_help))
1278 1276 {
1279 1277 }
1280 1278  
... ... @@ -1286,11 +1284,10 @@ namespace cxxopts
1286 1284  
1287 1285 class Options
1288 1286 {
1289   - typedef std::unordered_map<std::string, std::shared_ptr<OptionDetails>>
1290   - OptionMap;
  1287 + using OptionMap = std::unordered_map<std::string, std::shared_ptr<OptionDetails>>;
1291 1288 public:
1292 1289  
1293   - Options(std::string program, std::string help_string = "")
  1290 + explicit Options(std::string program, std::string help_string = "")
1294 1291 : m_program(std::move(program))
1295 1292 , m_help_string(toLocalString(std::move(help_string)))
1296 1293 , m_custom_help("[OPTION...]")
... ... @@ -1357,7 +1354,7 @@ namespace cxxopts
1357 1354 const std::string& s,
1358 1355 const std::string& l,
1359 1356 std::string desc,
1360   - std::shared_ptr<const Value> value,
  1357 + const std::shared_ptr<const Value>& value,
1361 1358 std::string arg_help
1362 1359 );
1363 1360  
... ... @@ -1380,7 +1377,7 @@ namespace cxxopts
1380 1377 std::string
1381 1378 help(const std::vector<std::string>& groups = {}) const;
1382 1379  
1383   - const std::vector<std::string>
  1380 + std::vector<std::string>
1384 1381 groups() const;
1385 1382  
1386 1383 const HelpGroupDetails&
... ... @@ -1392,7 +1389,7 @@ namespace cxxopts
1392 1389 add_one_option
1393 1390 (
1394 1391 const std::string& option,
1395   - std::shared_ptr<OptionDetails> details
  1392 + const std::shared_ptr<OptionDetails>& details
1396 1393 );
1397 1394  
1398 1395 String
... ... @@ -1438,7 +1435,7 @@ namespace cxxopts
1438 1435 (
1439 1436 const std::string& opts,
1440 1437 const std::string& desc,
1441   - std::shared_ptr<const Value> value
  1438 + const std::shared_ptr<const Value>& value
1442 1439 = ::cxxopts::value<bool>(),
1443 1440 std::string arg_help = ""
1444 1441 );
... ... @@ -1465,12 +1462,12 @@ namespace cxxopts
1465 1462 const HelpOptionDetails& o
1466 1463 )
1467 1464 {
1468   - auto& s = o.s;
1469   - auto& l = o.l;
  1465 + const auto& s = o.s;
  1466 + const auto& l = o.l;
1470 1467  
1471 1468 String result = " ";
1472 1469  
1473   - if (s.size() > 0)
  1470 + if (!s.empty())
1474 1471 {
1475 1472 result += "-" + toLocalString(s) + ",";
1476 1473 }
... ... @@ -1479,12 +1476,12 @@ namespace cxxopts
1479 1476 result += " ";
1480 1477 }
1481 1478  
1482   - if (l.size() > 0)
  1479 + if (!l.empty())
1483 1480 {
1484 1481 result += " --" + toLocalString(l);
1485 1482 }
1486 1483  
1487   - auto arg = o.arg_help.size() > 0 ? toLocalString(o.arg_help) : "arg";
  1484 + auto arg = !o.arg_help.empty() ? toLocalString(o.arg_help) : "arg";
1488 1485  
1489 1486 if (!o.is_boolean)
1490 1487 {
... ... @@ -1513,7 +1510,7 @@ namespace cxxopts
1513 1510  
1514 1511 if (o.has_default && (!o.is_boolean || o.default_value != "false"))
1515 1512 {
1516   - if(o.default_value != "")
  1513 + if(!o.default_value.empty())
1517 1514 {
1518 1515 desc += toLocalString(" (default: " + o.default_value + ")");
1519 1516 }
... ... @@ -1576,19 +1573,19 @@ namespace cxxopts
1576 1573  
1577 1574 return result;
1578 1575 }
1579   - }
  1576 + } // namespace
1580 1577  
1581 1578 inline
1582 1579 ParseResult::ParseResult
1583 1580 (
1584   - const std::shared_ptr<
  1581 + std::shared_ptr<
1585 1582 std::unordered_map<std::string, std::shared_ptr<OptionDetails>>
1586 1583 > options,
1587 1584 std::vector<std::string> positional,
1588 1585 bool allow_unrecognised,
1589 1586 int& argc, char**& argv
1590 1587 )
1591   -: m_options(options)
  1588 +: m_options(std::move(options))
1592 1589 , m_positional(std::move(positional))
1593 1590 , m_next_positional(m_positional.begin())
1594 1591 , m_allow_unrecognised(allow_unrecognised)
... ... @@ -1624,7 +1621,7 @@ OptionAdder::operator()
1624 1621 (
1625 1622 const std::string& opts,
1626 1623 const std::string& desc,
1627   - std::shared_ptr<const Value> value,
  1624 + const std::shared_ptr<const Value>& value,
1628 1625 std::string arg_help
1629 1626 )
1630 1627 {
... ... @@ -1657,10 +1654,7 @@ OptionAdder::operator()
1657 1654 {
1658 1655 return std::make_tuple(long_.str(), short_.str());
1659 1656 }
1660   - else
1661   - {
1662   - return std::make_tuple(short_.str(), long_.str());
1663   - }
  1657 + return std::make_tuple(short_.str(), long_.str());
1664 1658 }(short_match, long_match);
1665 1659  
1666 1660 m_options.add_option
... ... @@ -1678,7 +1672,7 @@ OptionAdder::operator()
1678 1672  
1679 1673 inline
1680 1674 void
1681   -ParseResult::parse_default(std::shared_ptr<OptionDetails> details)
  1675 +ParseResult::parse_default(const std::shared_ptr<OptionDetails>& details)
1682 1676 {
1683 1677 m_results[details].parse_default(details);
1684 1678 }
... ... @@ -1687,7 +1681,7 @@ inline
1687 1681 void
1688 1682 ParseResult::parse_option
1689 1683 (
1690   - std::shared_ptr<OptionDetails> value,
  1684 + const std::shared_ptr<OptionDetails>& value,
1691 1685 const std::string& /*name*/,
1692 1686 const std::string& arg
1693 1687 )
... ... @@ -1705,7 +1699,7 @@ ParseResult::checked_parse_arg
1705 1699 int argc,
1706 1700 char* argv[],
1707 1701 int& current,
1708   - std::shared_ptr<OptionDetails> value,
  1702 + const std::shared_ptr<OptionDetails>& value,
1709 1703 const std::string& name
1710 1704 )
1711 1705 {
... ... @@ -1750,7 +1744,7 @@ ParseResult::add_to_option(const std::string&amp; option, const std::string&amp; arg)
1750 1744  
1751 1745 inline
1752 1746 bool
1753   -ParseResult::consume_positional(std::string a)
  1747 +ParseResult::consume_positional(const std::string& a)
1754 1748 {
1755 1749 while (m_next_positional != m_positional.end())
1756 1750 {
... ... @@ -1766,22 +1760,13 @@ ParseResult::consume_positional(std::string a)
1766 1760 ++m_next_positional;
1767 1761 return true;
1768 1762 }
1769   - else
1770   - {
1771   - ++m_next_positional;
1772   - continue;
1773   - }
  1763 + ++m_next_positional;
  1764 + continue;
1774 1765 }
1775   - else
1776   - {
1777   - add_to_option(*m_next_positional, a);
1778   - return true;
1779   - }
1780   - }
1781   - else
1782   - {
1783   - throw_or_mimic<option_not_exists_exception>(*m_next_positional);
  1766 + add_to_option(*m_next_positional, a);
  1767 + return true;
1784 1768 }
  1769 + throw_or_mimic<option_not_exists_exception>(*m_next_positional);
1785 1770 }
1786 1771  
1787 1772 return false;
... ... @@ -1808,7 +1793,7 @@ inline
1808 1793 void
1809 1794 Options::parse_positional(std::initializer_list<std::string> options)
1810 1795 {
1811   - parse_positional(std::vector<std::string>(std::move(options)));
  1796 + parse_positional(std::vector<std::string>(options));
1812 1797 }
1813 1798  
1814 1799 inline
... ... @@ -1882,11 +1867,8 @@ ParseResult::parse(int&amp; argc, char**&amp; argv)
1882 1867 {
1883 1868 continue;
1884 1869 }
1885   - else
1886   - {
1887   - //error
1888   - throw_or_mimic<option_not_exists_exception>(name);
1889   - }
  1870 + //error
  1871 + throw_or_mimic<option_not_exists_exception>(name);
1890 1872 }
1891 1873  
1892 1874 auto value = iter->second;
... ... @@ -1923,11 +1905,8 @@ ParseResult::parse(int&amp; argc, char**&amp; argv)
1923 1905 ++current;
1924 1906 continue;
1925 1907 }
1926   - else
1927   - {
1928   - //error
1929   - throw_or_mimic<option_not_exists_exception>(name);
1930   - }
  1908 + //error
  1909 + throw_or_mimic<option_not_exists_exception>(name);
1931 1910 }
1932 1911  
1933 1912 auto opt = iter->second;
... ... @@ -1954,7 +1933,7 @@ ParseResult::parse(int&amp; argc, char**&amp; argv)
1954 1933 for (auto& opt : *m_options)
1955 1934 {
1956 1935 auto& detail = opt.second;
1957   - auto& value = detail->value();
  1936 + const auto& value = detail->value();
1958 1937  
1959 1938 auto& store = m_results[detail];
1960 1939  
... ... @@ -2004,19 +1983,19 @@ Options::add_option
2004 1983 const std::string& s,
2005 1984 const std::string& l,
2006 1985 std::string desc,
2007   - std::shared_ptr<const Value> value,
  1986 + const std::shared_ptr<const Value>& value,
2008 1987 std::string arg_help
2009 1988 )
2010 1989 {
2011 1990 auto stringDesc = toLocalString(std::move(desc));
2012 1991 auto option = std::make_shared<OptionDetails>(s, l, stringDesc, value);
2013 1992  
2014   - if (s.size() > 0)
  1993 + if (!s.empty())
2015 1994 {
2016 1995 add_one_option(s, option);
2017 1996 }
2018 1997  
2019   - if (l.size() > 0)
  1998 + if (!l.empty())
2020 1999 {
2021 2000 add_one_option(l, option);
2022 2001 }
... ... @@ -2037,7 +2016,7 @@ void
2037 2016 Options::add_one_option
2038 2017 (
2039 2018 const std::string& option,
2040   - std::shared_ptr<OptionDetails> details
  2019 + const std::shared_ptr<OptionDetails>& details
2041 2020 )
2042 2021 {
2043 2022 auto in = m_options->emplace(option, details);
... ... @@ -2052,7 +2031,7 @@ inline
2052 2031 String
2053 2032 Options::help_one_group(const std::string& g) const
2054 2033 {
2055   - typedef std::vector<std::pair<String, String>> OptionHelp;
  2034 + using OptionHelp = std::vector<std::pair<String, String>>;
2056 2035  
2057 2036 auto group = m_help.find(g);
2058 2037 if (group == m_help.end())
... ... @@ -2151,7 +2130,7 @@ Options::generate_all_groups_help(String&amp; result) const
2151 2130 std::vector<std::string> all_groups;
2152 2131 all_groups.reserve(m_help.size());
2153 2132  
2154   - for (auto& group : m_help)
  2133 + for (const auto& group : m_help)
2155 2134 {
2156 2135 all_groups.push_back(group.first);
2157 2136 }
... ... @@ -2166,13 +2145,13 @@ Options::help(const std::vector&lt;std::string&gt;&amp; help_groups) const
2166 2145 String result = m_help_string + "\nUsage:\n " +
2167 2146 toLocalString(m_program) + " " + toLocalString(m_custom_help);
2168 2147  
2169   - if (m_positional.size() > 0 && m_positional_help.size() > 0) {
  2148 + if (!m_positional.empty() && !m_positional_help.empty()) {
2170 2149 result += " " + toLocalString(m_positional_help);
2171 2150 }
2172 2151  
2173 2152 result += "\n\n";
2174 2153  
2175   - if (help_groups.size() == 0)
  2154 + if (help_groups.empty())
2176 2155 {
2177 2156 generate_all_groups_help(result);
2178 2157 }
... ... @@ -2185,7 +2164,7 @@ Options::help(const std::vector&lt;std::string&gt;&amp; help_groups) const
2185 2164 }
2186 2165  
2187 2166 inline
2188   -const std::vector<std::string>
  2167 +std::vector<std::string>
2189 2168 Options::groups() const
2190 2169 {
2191 2170 std::vector<std::string> g;
... ... @@ -2210,6 +2189,6 @@ Options::group_help(const std::string&amp; group) const
2210 2189 return m_help.at(group);
2211 2190 }
2212 2191  
2213   -}
  2192 +} // namespace cxxopts
2214 2193  
2215 2194 #endif //CXXOPTS_HPP_INCLUDED
... ...