aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor C. Richberger <taywee@gmx.com>2019-02-15 12:21:20 -0700
committerGitHub <noreply@github.com>2019-02-15 12:21:20 -0700
commit8f8f1db3fe43fd1401fd55e6249838433721304f (patch)
tree03f31005ae8d6256fb9b3307919e30aec3009842
parentFix default list processing (diff)
parentRemove signed <-> unsigned warnings around size_t (diff)
downloadargs.hxx-8f8f1db3fe43fd1401fd55e6249838433721304f.tar.xz
Merge pull request #72 from mrkline/fix-sign-warnings
Remove signed <-> unsigned warnings around size_t
-rw-r--r--args.hxx12
1 files changed, 8 insertions, 4 deletions
diff --git a/args.hxx b/args.hxx
index bbc521d..d7b3ca9 100644
--- a/args.hxx
+++ b/args.hxx
@@ -1470,7 +1470,9 @@ namespace args
*/
std::vector<Base *>::size_type MatchedChildren() const
{
- return std::count_if(std::begin(Children()), std::end(Children()), [](const Base *child){return child->Matched();});
+ // Cast to avoid warnings from -Wsign-conversion
+ return static_cast<std::vector<Base *>::size_type>(
+ std::count_if(std::begin(Children()), std::end(Children()), [](const Base *child){return child->Matched();}));
}
/** Whether or not this group matches validation
@@ -2697,7 +2699,7 @@ namespace args
#endif
readCompletion = true;
++it;
- size_t argsLeft = std::distance(it, end);
+ const auto argsLeft = static_cast<size_t>(std::distance(it, end));
if (completion->cword == 0 || argsLeft <= 1 || completion->cword >= argsLeft)
{
#ifndef ARGS_NOEXCEPT
@@ -2716,13 +2718,15 @@ namespace args
if (idx > 0 && curArgs[idx] == "=")
{
curArgs[idx - 1] += "=";
+ // Avoid warnings from -Wsign-conversion
+ const auto signedIdx = static_cast<ptrdiff_t>(idx);
if (idx + 1 < curArgs.size())
{
curArgs[idx - 1] += curArgs[idx + 1];
- curArgs.erase(curArgs.begin() + idx, curArgs.begin() + idx + 2);
+ curArgs.erase(curArgs.begin() + signedIdx, curArgs.begin() + signedIdx + 2);
} else
{
- curArgs.erase(curArgs.begin() + idx);
+ curArgs.erase(curArgs.begin() + signedIdx);
}
} else
{