Commit ed85f04a1b4e6a472f8973971c1f6c69b8afc02f
Committed by
GitHub
1 parent
834fb999
clang-tidy stuff (#266)
Several clang-tidy improvements.
Showing
1 changed file
with
19 additions
and
16 deletions
include/cxxopts.hpp
| ... | ... | @@ -82,7 +82,7 @@ namespace cxxopts |
| 82 | 82 | |
| 83 | 83 | namespace cxxopts |
| 84 | 84 | { |
| 85 | - typedef icu::UnicodeString String; | |
| 85 | + using String = icu::UnicodeString; | |
| 86 | 86 | |
| 87 | 87 | inline |
| 88 | 88 | String |
| ... | ... | @@ -217,7 +217,7 @@ namespace std |
| 217 | 217 | |
| 218 | 218 | namespace cxxopts |
| 219 | 219 | { |
| 220 | - typedef std::string String; | |
| 220 | + using String = std::string; | |
| 221 | 221 | |
| 222 | 222 | template <typename T> |
| 223 | 223 | T |
| ... | ... | @@ -562,7 +562,7 @@ namespace cxxopts |
| 562 | 562 | { |
| 563 | 563 | template <typename U> |
| 564 | 564 | void |
| 565 | - operator()(bool, U, const std::string&) {} | |
| 565 | + operator()(bool, U, const std::string&) const {} | |
| 566 | 566 | }; |
| 567 | 567 | |
| 568 | 568 | template <typename T, typename U> |
| ... | ... | @@ -1030,9 +1030,9 @@ namespace cxxopts |
| 1030 | 1030 | |
| 1031 | 1031 | OptionDetails(const OptionDetails& rhs) |
| 1032 | 1032 | : m_desc(rhs.m_desc) |
| 1033 | + , m_value(rhs.m_value->clone()) | |
| 1033 | 1034 | , m_count(rhs.m_count) |
| 1034 | 1035 | { |
| 1035 | - m_value = rhs.m_value->clone(); | |
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | 1038 | OptionDetails(OptionDetails&& rhs) = default; |
| ... | ... | @@ -1236,8 +1236,7 @@ namespace cxxopts |
| 1236 | 1236 | { |
| 1237 | 1237 | public: |
| 1238 | 1238 | |
| 1239 | - ParseResult() {} | |
| 1240 | - | |
| 1239 | + ParseResult() = default; | |
| 1241 | 1240 | ParseResult(const ParseResult&) = default; |
| 1242 | 1241 | |
| 1243 | 1242 | ParseResult(NameHashMap&& keys, ParsedHashMap&& values, std::vector<KeyValue> sequential, std::vector<std::string>&& unmatched_args) |
| ... | ... | @@ -1840,9 +1839,9 @@ OptionParser::consume_positional(const std::string& a, PositionalListIterator& n |
| 1840 | 1839 | auto iter = m_options.find(*next); |
| 1841 | 1840 | if (iter != m_options.end()) |
| 1842 | 1841 | { |
| 1843 | - auto& result = m_parsed[iter->second->hash()]; | |
| 1844 | 1842 | if (!iter->second->value().is_container()) |
| 1845 | 1843 | { |
| 1844 | + auto& result = m_parsed[iter->second->hash()]; | |
| 1846 | 1845 | if (result.count() == 0) |
| 1847 | 1846 | { |
| 1848 | 1847 | add_to_option(iter, *next, a); |
| ... | ... | @@ -1898,7 +1897,7 @@ OptionParser::parse(int argc, const char* const* argv) |
| 1898 | 1897 | { |
| 1899 | 1898 | int current = 1; |
| 1900 | 1899 | bool consume_remaining = false; |
| 1901 | - PositionalListIterator next_positional = m_positional.begin(); | |
| 1900 | + auto next_positional = m_positional.begin(); | |
| 1902 | 1901 | |
| 1903 | 1902 | std::vector<std::string> unmatched; |
| 1904 | 1903 | |
| ... | ... | @@ -1932,7 +1931,7 @@ OptionParser::parse(int argc, const char* const* argv) |
| 1932 | 1931 | } |
| 1933 | 1932 | else |
| 1934 | 1933 | { |
| 1935 | - unmatched.push_back(argv[current]); | |
| 1934 | + unmatched.emplace_back(argv[current]); | |
| 1936 | 1935 | } |
| 1937 | 1936 | //if we return from here then it was parsed successfully, so continue |
| 1938 | 1937 | } |
| ... | ... | @@ -1987,7 +1986,7 @@ OptionParser::parse(int argc, const char* const* argv) |
| 1987 | 1986 | if (m_allow_unrecognised) |
| 1988 | 1987 | { |
| 1989 | 1988 | // keep unrecognised options in argument list, skip to next argument |
| 1990 | - unmatched.push_back(argv[current]); | |
| 1989 | + unmatched.emplace_back(argv[current]); | |
| 1991 | 1990 | ++current; |
| 1992 | 1991 | continue; |
| 1993 | 1992 | } |
| ... | ... | @@ -2040,7 +2039,7 @@ OptionParser::parse(int argc, const char* const* argv) |
| 2040 | 2039 | |
| 2041 | 2040 | //adjust argv for any that couldn't be swallowed |
| 2042 | 2041 | while (current != argc) { |
| 2043 | - unmatched.push_back(argv[current]); | |
| 2042 | + unmatched.emplace_back(argv[current]); | |
| 2044 | 2043 | ++current; |
| 2045 | 2044 | } |
| 2046 | 2045 | } |
| ... | ... | @@ -2235,12 +2234,16 @@ void |
| 2235 | 2234 | Options::generate_all_groups_help(String& result) const |
| 2236 | 2235 | { |
| 2237 | 2236 | std::vector<std::string> all_groups; |
| 2238 | - all_groups.reserve(m_help.size()); | |
| 2239 | 2237 | |
| 2240 | - for (const auto& group : m_help) | |
| 2241 | - { | |
| 2242 | - all_groups.push_back(group.first); | |
| 2243 | - } | |
| 2238 | + std::transform( | |
| 2239 | + m_help.begin(), | |
| 2240 | + m_help.end(), | |
| 2241 | + std::back_inserter(all_groups), | |
| 2242 | + [] (const std::map<std::string, HelpGroupDetails>::value_type& group) | |
| 2243 | + { | |
| 2244 | + return group.first; | |
| 2245 | + } | |
| 2246 | + ); | |
| 2244 | 2247 | |
| 2245 | 2248 | generate_group_help(result, all_groups); |
| 2246 | 2249 | } | ... | ... |