/*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
template <class Value>
class InfiniteImpl {
public:
- bool test(const Value& current) const { return true; }
+ bool test(const Value& /* current */) const { return true; }
void step(Value& current) const { ++current; }
static constexpr bool infinite = true;
};
"false or hang. 'any' or 'notEmpty' will either return true "
"or hang.");
bool ans = emptyResult;
- source | [&](Value v) -> bool {
- ans = !emptyResult;
- return false;
- };
+ source |
+ [&](Value /* v */) -> bool {
+ ans = !emptyResult;
+ return false;
+ };
return ans;
}
};
size_t compose(const GenImpl<Value, Source>& source) const {
static_assert(!Source::infinite, "Cannot count infinite source");
return foldl(size_t(0),
- [](size_t accum, Value v) {
- return accum + 1;
- }).compose(source);
+ [](size_t accum, Value /* v */) { return accum + 1; })
+ .compose(source);
}
};
constexpr detail::Unwrap unwrap{};
-inline detail::Take take(size_t count) { return detail::Take(count); }
+template <class Number>
+inline detail::Take take(Number count) {
+ if (count < 0) {
+ throw std::invalid_argument("Negative value passed to take()");
+ }
+ return detail::Take(static_cast<size_t>(count));
+}
inline detail::Stride stride(size_t s) { return detail::Stride(s); }