return Composed(std::move(left.self()), std::move(right.self()));
}
-template<class Value,
- class Source,
- class Yield = detail::Yield<Value, Source>>
-Yield operator+(const detail::GeneratorBuilder<Value>&,
- Source&& source) {
- return Yield(std::forward<Source>(source));
-}
-
/**
* GenImpl - Core abstraction of a generator, an object which produces values by
* passing them to a given handler lambda. All generator implementations must
!std::is_const<Value>::value, "Value mustn't be const or ref.");
Value bounds_[endless ? 1 : 2];
public:
- explicit Sequence(const Value& begin)
- : bounds_{begin} {
+ explicit Sequence(Value begin)
+ : bounds_{std::move(begin)} {
static_assert(endless, "Must supply 'end'");
}
- explicit Sequence(const Value& begin, const Value& end)
- : bounds_{begin, end} {}
+ Sequence(Value begin,
+ Value end)
+ : bounds_{std::move(begin), std::move(end)} {}
template<class Handler>
bool apply(Handler&& handler) const {
}
};
+/**
+ * GenratorBuilder - Helper for GENERTATOR macro.
+ **/
+template<class Value>
+struct GeneratorBuilder {
+ template<class Source,
+ class Yield = detail::Yield<Value, Source>>
+ Yield operator+(Source&& source) {
+ return Yield(std::forward<Source>(source));
+ }
+};
+
/**
* Yield - For producing values from a user-defined generator by way of a
* 'yield' function.
class Map : public Operator<Map<Predicate>> {
Predicate pred_;
public:
- explicit Map(const Predicate& pred = Predicate())
- : pred_(pred)
+ Map() {}
+
+ explicit Map(Predicate pred)
+ : pred_(std::move(pred))
{ }
template<class Value,
class Filter : public Operator<Filter<Predicate>> {
Predicate pred_;
public:
- explicit Filter(const Predicate& pred = Predicate())
- : pred_(pred)
+ Filter() {}
+ explicit Filter(Predicate pred)
+ : pred_(std::move(pred))
{ }
template<class Value,
class Until : public Operator<Until<Predicate>> {
Predicate pred_;
public:
- explicit Until(const Predicate& pred = Predicate())
- : pred_(pred)
- { }
+ Until() {}
+ explicit Until(Predicate pred)
+ : pred_(std::move(pred))
+ {}
template<class Value,
class Source,
Selector selector_;
Comparer comparer_;
public:
- explicit Order(const Selector& selector = Selector(),
- const Comparer& comparer = Comparer())
- : selector_(selector) , comparer_(comparer) {}
+ Order() {}
+
+ explicit Order(Selector selector)
+ : selector_(std::move(selector))
+ {}
+
+ Order(Selector selector,
+ Comparer comparer)
+ : selector_(std::move(selector))
+ , comparer_(std::move(comparer))
+ {}
template<class Value,
class Source,
Seed seed_;
Fold fold_;
public:
- FoldLeft(const Seed& seed, const Fold& fold)
- : seed_(seed)
- , fold_(fold)
+ FoldLeft() {}
+ FoldLeft(Seed seed,
+ Fold fold)
+ : seed_(std::move(seed))
+ , fold_(std::move(fold))
{}
template<class Source,
class All : public Operator<All<Predicate>> {
Predicate pred_;
public:
- explicit All(const Predicate& pred = Predicate())
- : pred_(pred)
+ All() {}
+ explicit All(Predicate pred)
+ : pred_(std::move(pred))
{ }
template<class Source,
class Reduce : public Operator<Reduce<Reducer>> {
Reducer reducer_;
public:
- explicit Reduce(const Reducer& reducer)
- : reducer_(reducer)
+ Reduce() {}
+ explicit Reduce(Reducer reducer)
+ : reducer_(std::move(reducer))
{}
template<class Source,
Selector selector_;
Comparer comparer_;
public:
- explicit Min(const Selector& selector = Selector(),
- const Comparer& comparer = Comparer())
- : selector_(selector)
- , comparer_(comparer)
+ Min() {}
+
+ explicit Min(Selector selector)
+ : selector_(std::move(selector))
+ {}
+
+ Min(Selector selector,
+ Comparer comparer)
+ : selector_(std::move(selector))
+ , comparer_(std::move(comparer))
{}
template<class Value,
class Append;
template<class Value>
-class GeneratorBuilder {};
+class GeneratorBuilder;
template<class Needle>
class Contains;
*/
template<class Predicate,
class Map = detail::Map<Predicate>>
-Map mapped(const Predicate& pred = Predicate()) {
- return Map(pred);
+Map mapped(Predicate pred = Predicate()) {
+ return Map(std::move(pred));
}
template<class Predicate,
class Map = detail::Map<Predicate>>
-Map map(const Predicate& pred = Predicate()) {
- return Map(pred);
+Map map(Predicate pred = Predicate()) {
+ return Map(std::move(pred));
}
template<class Predicate,
template<class Selector,
class Comparer = Less,
class Order = detail::Order<Selector, Comparer>>
-Order orderBy(const Selector& selector,
- const Comparer& comparer = Comparer()) {
- return Order(selector, comparer);
+Order orderBy(Selector selector = Identity(),
+ Comparer comparer = Comparer()) {
+ return Order(std::move(selector),
+ std::move(comparer));
}
template<class Selector,
class Order = detail::Order<Selector, Greater>>
-Order orderByDescending(const Selector& selector) {
- return Order(selector);
+Order orderByDescending(Selector selector = Identity()) {
+ return Order(std::move(selector));
}
template<int n,
template<class Seed,
class Fold,
class FoldLeft = detail::FoldLeft<Seed, Fold>>
-FoldLeft foldl(const Seed& seed, const Fold& fold) {
- return FoldLeft(seed, fold);
+FoldLeft foldl(Seed seed = Seed(),
+ Fold fold = Fold()) {
+ return FoldLeft(std::move(seed),
+ std::move(fold));
}
template<class Reducer,
class Reduce = detail::Reduce<Reducer>>
-Reduce reduce(const Reducer& reducer) {
- return Reduce(reducer);
+Reduce reduce(Reducer reducer = Reducer()) {
+ return Reduce(std::move(reducer));
}
-template<class Selector,
+template<class Selector = Identity,
class Min = detail::Min<Selector, Less>>
-Min minBy(const Selector& selector = Selector()) {
- return Min(selector);
+Min minBy(Selector selector = Selector()) {
+ return Min(std::move(selector));
}
template<class Selector,
class MaxBy = detail::Min<Selector, Greater>>
-MaxBy maxBy(const Selector& selector = Selector()) {
- return MaxBy(selector);
+MaxBy maxBy(Selector selector = Selector()) {
+ return MaxBy(std::move(selector));
}
template<class Collection,