**/
template <class Value>
struct GeneratorBuilder {
- template <class Source,
- class Yield = detail::Yield<Value, Source>>
+ template <class Source, class Yield = detail::Yield<Value, Source>>
Yield operator+(Source&& source) {
return Yield(std::forward<Source>(source));
}
explicit Map(Predicate pred) : pred_(std::move(pred)) {}
- template <class Value,
- class Source,
- class Result = typename ArgumentReference<
- typename std::result_of<Predicate(Value)>::type>::type>
+ template <
+ class Value,
+ class Source,
+ class Result = typename ArgumentReference<
+ typename std::result_of<Predicate(Value)>::type>::type>
class Generator : public GenImpl<Result, Generator<Value, Source, Result>> {
Source source_;
Predicate pred_;
static constexpr bool infinite = Source::infinite;
};
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), pred_);
}
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), pred_);
}
static constexpr bool infinite = Source::infinite;
};
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), pred_);
}
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), pred_);
}
static constexpr bool infinite = false;
};
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), pred_);
}
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), pred_);
}
static constexpr bool infinite = false;
};
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), count_);
}
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), count_);
}
static constexpr bool infinite = Source::infinite;
};
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), stride_);
}
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), stride_);
}
explicit Sample(size_t count, Random rng)
: count_(count), rng_(std::move(rng)) {}
- template <class Value,
- class Source,
- class Rand,
- class StorageType = typename std::decay<Value>::type>
+ template <
+ class Value,
+ class Source,
+ class Rand,
+ class StorageType = typename std::decay<Value>::type>
class Generator
: public GenImpl<StorageType&&,
Generator<Value, Source, Rand, StorageType>> {
static constexpr bool infinite = false;
};
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source, Random>>
+ template <
+ class Source,
+ class Value,
+ class Gen = Generator<Value, Source, Random>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), count_, rng_);
}
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source, Random>>
+ template <
+ class Source,
+ class Value,
+ class Gen = Generator<Value, Source, Random>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), count_, rng_);
}
static constexpr bool infinite = Source::infinite;
};
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), count_);
}
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), count_);
}
Order(Selector selector, Comparer comparer)
: selector_(std::move(selector)), comparer_(std::move(comparer)) {}
- template <class Value,
- class Source,
- class StorageType = typename std::decay<Value>::type,
- class Result = typename std::result_of<Selector(Value)>::type>
+ template <
+ class Value,
+ class Source,
+ class StorageType = typename std::decay<Value>::type,
+ class Result = typename std::result_of<Selector(Value)>::type>
class Generator
: public GenImpl<StorageType&&,
Generator<Value, Source, StorageType, Result>> {
static constexpr bool infinite = false;
};
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), selector_, comparer_);
}
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), selector_, comparer_);
}
explicit GroupBy(Selector selector) : selector_(std::move(selector)) {}
- template <class Value,
- class Source,
- class ValueDecayed = typename std::decay<Value>::type,
- class Key = typename std::result_of<Selector(Value)>::type,
- class KeyDecayed = typename std::decay<Key>::type>
+ template <
+ class Value,
+ class Source,
+ class ValueDecayed = typename std::decay<Value>::type,
+ class Key = typename std::result_of<Selector(Value)>::type,
+ class KeyDecayed = typename std::decay<Key>::type>
class Generator
: public GenImpl<
Group<KeyDecayed, ValueDecayed>&&,
static constexpr bool infinite = false;
};
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), selector_);
}
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), selector_);
}
static constexpr bool infinite = Source::infinite;
};
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), selector_);
}
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), selector_);
}
public:
explicit Composer(Operators op) : op_(std::move(op)) {}
- template <class Source,
- class Ret = decltype(
- std::declval<Operators>().compose(std::declval<Source>()))>
+ template <
+ class Source,
+ class Ret =
+ decltype(std::declval<Operators>().compose(std::declval<Source>()))>
Ret operator()(Source&& source) const {
return op_.compose(std::forward<Source>(source));
}
}
}
- template <class Value,
- class Source,
- class StorageType = typename std::decay<Value>::type,
- class VectorType = std::vector<StorageType>>
+ template <
+ class Value,
+ class Source,
+ class StorageType = typename std::decay<Value>::type,
+ class VectorType = std::vector<StorageType>>
class Generator
: public GenImpl<VectorType&,
Generator<Value, Source, StorageType, VectorType>> {
static constexpr bool infinite = Source::infinite;
};
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), batchSize_);
}
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), batchSize_);
}
public:
Concat() = default;
- template <class Inner,
- class Source,
- class InnerValue = typename std::decay<Inner>::type::ValueType>
+ template <
+ class Inner,
+ class Source,
+ class InnerValue = typename std::decay<Inner>::type::ValueType>
class Generator
: public GenImpl<InnerValue, Generator<Inner, Source, InnerValue>> {
Source source_;
Source::infinite || std::decay<Inner>::type::infinite;
};
- template <class Value,
- class Source,
- class Gen = Generator<Value, Source>>
+ template <class Value, class Source, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()));
}
- template <class Value,
- class Source,
- class Gen = Generator<Value, Source>>
+ template <class Value, class Source, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self());
}
public:
RangeConcat() = default;
- template <class Range,
- class Source,
- class InnerValue = typename ValueTypeOfRange<Range>::RefType>
+ template <
+ class Range,
+ class Source,
+ class InnerValue = typename ValueTypeOfRange<Range>::RefType>
class Generator
: public GenImpl<InnerValue, Generator<Range, Source, InnerValue>> {
Source source_;
static constexpr bool infinite = Source::infinite;
};
- template <class Value,
- class Source,
- class Gen = Generator<Value, Source>>
+ template <class Value, class Source, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()));
}
- template <class Value,
- class Source,
- class Gen = Generator<Value, Source>>
+ template <class Value, class Source, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self());
}
static constexpr bool infinite = Source::infinite;
};
- template <class Value,
- class Source,
- class Gen = Generator<Value, Source>>
+ template <class Value, class Source, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), handler_);
}
- template <class Value,
- class Source,
- class Gen = Generator<Value, Source>>
+ template <class Value, class Source, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), handler_);
}
public:
Dereference() = default;
- template <class Value,
- class Source,
- class Result = decltype(*std::declval<Value>())>
+ template <
+ class Value,
+ class Source,
+ class Result = decltype(*std::declval<Value>())>
class Generator : public GenImpl<Result, Generator<Value, Source, Result>> {
Source source_;
static constexpr bool infinite = Source::infinite;
};
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()));
}
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self());
}
public:
Indirect() = default;
- template <class Value,
- class Source,
- class Result = typename std::remove_reference<Value>::type*>
+ template <
+ class Value,
+ class Source,
+ class Result = typename std::remove_reference<Value>::type*>
class Generator : public GenImpl<Result, Generator<Value, Source, Result>> {
Source source_;
static_assert(!std::is_rvalue_reference<Value>::value,
static constexpr bool infinite = Source::infinite;
};
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()));
}
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self());
}
static constexpr bool infinite = forever || Source::infinite;
};
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), limit_);
}
- template <class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), limit_);
}
public:
First() = default;
- template <class Source,
- class Value,
- class StorageType = typename std::decay<Value>::type>
+ template <
+ class Source,
+ class Value,
+ class StorageType = typename std::decay<Value>::type>
Optional<StorageType> compose(const GenImpl<Value, Source>& source) const {
Optional<StorageType> accum;
source | [&](Value v) -> bool {
Reduce() = default;
explicit Reduce(Reducer reducer) : reducer_(std::move(reducer)) {}
- template <class Source,
- class Value,
- class StorageType = typename std::decay<Value>::type>
+ template <
+ class Source,
+ class Value,
+ class StorageType = typename std::decay<Value>::type>
Optional<StorageType> compose(const GenImpl<Value, Source>& source) const {
static_assert(!Source::infinite, "Cannot reduce infinite source");
Optional<StorageType> accum;
public:
Sum() = default;
- template <class Source,
- class Value,
- class StorageType = typename std::decay<Value>::type>
+ template <
+ class Source,
+ class Value,
+ class StorageType = typename std::decay<Value>::type>
StorageType compose(const GenImpl<Value, Source>& source) const {
static_assert(!Source::infinite, "Cannot sum infinite source");
return foldl(StorageType(0),
public:
explicit Contains(Needle needle) : needle_(std::move(needle)) {}
- template <class Source,
- class Value,
- class StorageType = typename std::decay<Value>::type>
+ template <
+ class Source,
+ class Value,
+ class StorageType = typename std::decay<Value>::type>
bool compose(const GenImpl<Value, Source>& source) const {
static_assert(!Source::infinite,
"Calling contains on an infinite source might cause "
Min(Selector selector, Comparer comparer)
: selector_(std::move(selector)), comparer_(std::move(comparer)) {}
- template <class Value,
- class Source,
- class StorageType = typename std::decay<Value>::type,
- class Key = typename std::decay<
- typename std::result_of<Selector(Value)>::type>::type>
+ template <
+ class Value,
+ class Source,
+ class StorageType = typename std::decay<Value>::type,
+ class Key = typename std::decay<
+ typename std::result_of<Selector(Value)>::type>::type>
Optional<StorageType> compose(const GenImpl<Value, Source>& source) const {
static_assert(!Source::infinite,
"Calling min or max on an infinite source will cause "
public:
Collect() = default;
- template <class Value,
- class Source,
- class StorageType = typename std::decay<Value>::type>
+ template <
+ class Value,
+ class Source,
+ class StorageType = typename std::decay<Value>::type>
Collection compose(const GenImpl<Value, Source>& source) const {
static_assert(!Source::infinite,
"Cannot convert infinite source to object with as.");
*
* set<string> uniqueNames = from(names) | as<set>();
*/
-template <template <class, class> class Container,
- template <class> class Allocator>
+template <
+ template <class, class> class Container,
+ template <class> class Allocator>
class CollectTemplate : public Operator<CollectTemplate<Container, Allocator>> {
public:
CollectTemplate() = default;
- template <class Value,
- class Source,
- class StorageType = typename std::decay<Value>::type,
- class Collection = Container<StorageType, Allocator<StorageType>>>
+ template <
+ class Value,
+ class Source,
+ class StorageType = typename std::decay<Value>::type,
+ class Collection = Container<StorageType, Allocator<StorageType>>>
Collection compose(const GenImpl<Value, Source>& source) const {
static_assert(!Source::infinite,
"Cannot convert infinite source to object with as.");
}
// Mixed type unwrapping always returns values, moving where possible
-template <class T,
- class U,
- class R = typename std::enable_if<
- !std::is_same<T, U>::value,
- typename std::common_type<T, U>::type>::type>
+template <
+ class T,
+ class U,
+ class R = typename std::enable_if<
+ !std::is_same<T, U>::value,
+ typename std::common_type<T, U>::type>::type>
R operator|(Optional<T>&& opt, UnwrapOr<U>&& fallback) {
if (T* p = opt.get_pointer()) {
return std::move(*p);
return std::move(fallback.value());
}
-template <class T,
- class U,
- class R = typename std::enable_if<
- !std::is_same<T, U>::value,
- typename std::common_type<T, U>::type>::type>
+template <
+ class T,
+ class U,
+ class R = typename std::enable_if<
+ !std::is_same<T, U>::value,
+ typename std::common_type<T, U>::type>::type>
R operator|(const Optional<T>& opt, UnwrapOr<U>&& fallback) {
if (const T* p = opt.get_pointer()) {
return *p;
return std::move(fallback.value());
}
-template <class T,
- class U,
- class R = typename std::enable_if<
- !std::is_same<T, U>::value,
- typename std::common_type<T, U>::type>::type>
+template <
+ class T,
+ class U,
+ class R = typename std::enable_if<
+ !std::is_same<T, U>::value,
+ typename std::common_type<T, U>::type>::type>
R operator|(Optional<T>&& opt, const UnwrapOr<U>& fallback) {
if (T* p = opt.get_pointer()) {
return std::move(*p);
return fallback.value();
}
-template <class T,
- class U,
- class R = typename std::enable_if<
- !std::is_same<T, U>::value,
- typename std::common_type<T, U>::type>::type>
+template <
+ class T,
+ class U,
+ class R = typename std::enable_if<
+ !std::is_same<T, U>::value,
+ typename std::common_type<T, U>::type>::type>
R operator|(const Optional<T>& opt, const UnwrapOr<U>& fallback) {
if (const T* p = opt.get_pointer()) {
return *p;
class Less {
public:
- template<class First,
- class Second>
+ template <class First, class Second>
auto operator()(const First& first, const Second& second) const ->
decltype(first < second) {
return first < second;
class Greater {
public:
- template<class First,
- class Second>
+ template <class First, class Second>
auto operator()(const First& first, const Second& second) const ->
decltype(first > second) {
return first > second;
}
};
-template<int n>
+template <int n>
class Get {
public:
- template<class Value>
+ template <class Value>
auto operator()(Value&& value) const ->
decltype(std::get<n>(std::forward<Value>(value))) {
return std::get<n>(std::forward<Value>(value));
}
};
-template<class Class,
- class Result>
+template <class Class, class Result>
class MemberFunction {
public:
typedef Result (Class::*MemberPtr)();
}
};
-template<class Class,
- class Result>
+template <class Class, class Result>
class ConstMemberFunction{
public:
typedef Result (Class::*MemberPtr)() const;
}
};
-template<class Class,
- class FieldType>
+template <class Class, class FieldType>
class Field {
public:
typedef FieldType (Class::*FieldPtr);
class Move {
public:
- template<class Value>
+ template <class Value>
auto operator()(Value&& value) const ->
decltype(std::move(std::forward<Value>(value))) {
return std::move(std::forward<Value>(value));
}
};
-template<class Key, class Value>
+template <class Key, class Value>
class Group;
namespace detail {
-template<class Self>
+template <class Self>
struct FBounded;
/*
* Type Traits
*/
-template<class Container>
+template <class Container>
struct ValueTypeOfRange {
public:
using RefType = decltype(*std::begin(std::declval<Container&>()));
/*
* Sources
*/
-template<class Container,
- class Value = typename ValueTypeOfRange<Container>::RefType>
+template <
+ class Container,
+ class Value = typename ValueTypeOfRange<Container>::RefType>
class ReferencedSource;
-template<class Value,
- class Container = std::vector<typename std::decay<Value>::type>>
+template <
+ class Value,
+ class Container = std::vector<typename std::decay<Value>::type>>
class CopiedSource;
-template<class Value, class SequenceImpl>
+template <class Value, class SequenceImpl>
class Sequence;
template <class Value>
template <class Value>
class InfiniteImpl;
-template<class Value, class Source>
+template <class Value, class Source>
class Yield;
-template<class Value>
+template <class Value>
class Empty;
-template<class Value>
+template <class Value>
class SingleReference;
-template<class Value>
+template <class Value>
class SingleCopy;
/*
* Operators
*/
-template<class Predicate>
+template <class Predicate>
class Map;
-template<class Predicate>
+template <class Predicate>
class Filter;
-template<class Predicate>
+template <class Predicate>
class Until;
class Take;
class Stride;
-template<class Rand>
+template <class Rand>
class Sample;
class Skip;
-template<class Selector, class Comparer = Less>
+template <class Selector, class Comparer = Less>
class Order;
-template<class Selector>
+template <class Selector>
class GroupBy;
-template<class Selector>
+template <class Selector>
class Distinct;
-template<class Operators>
+template <class Operators>
class Composer;
-template<class Expected>
+template <class Expected>
class TypeAssertion;
class Concat;
/*
* Sinks
*/
-template<class Seed,
- class Fold>
+template <class Seed, class Fold>
class FoldLeft;
class First;
template <bool result>
class IsEmpty;
-template<class Reducer>
+template <class Reducer>
class Reduce;
class Sum;
-template<class Selector,
- class Comparer>
+template <class Selector, class Comparer>
class Min;
-template<class Container>
+template <class Container>
class Collect;
-template<template<class, class> class Collection = std::vector,
- template<class> class Allocator = std::allocator>
+template <
+ template <class, class> class Collection = std::vector,
+ template <class> class Allocator = std::allocator>
class CollectTemplate;
-template<class Collection>
+template <class Collection>
class Append;
-template<class Value>
+template <class Value>
struct GeneratorBuilder;
-template<class Needle>
+template <class Needle>
class Contains;
-template<class Exception,
- class ErrorHandler>
+template <class Exception, class ErrorHandler>
class GuardImpl;
template <class T>
/**
* Polymorphic wrapper
**/
-template<class Value>
+template <class Value>
class VirtualGen;
/*
* Source Factories
*/
-template<class Container,
- class From = detail::ReferencedSource<const Container>>
+template <
+ class Container,
+ class From = detail::ReferencedSource<const Container>>
From fromConst(const Container& source) {
return From(&source);
}
-template<class Container,
- class From = detail::ReferencedSource<Container>>
+template <class Container, class From = detail::ReferencedSource<Container>>
From from(Container& source) {
return From(&source);
}
-template<class Container,
- class Value =
- typename detail::ValueTypeOfRange<Container>::StorageType,
- class CopyOf = detail::CopiedSource<Value>>
+template <
+ class Container,
+ class Value = typename detail::ValueTypeOfRange<Container>::StorageType,
+ class CopyOf = detail::CopiedSource<Value>>
CopyOf fromCopy(Container&& source) {
return CopyOf(std::forward<Container>(source));
}
-template<class Value,
- class From = detail::CopiedSource<Value>>
+template <class Value, class From = detail::CopiedSource<Value>>
From from(std::initializer_list<Value> source) {
return From(source);
}
-template<class Container,
- class From = detail::CopiedSource<typename Container::value_type,
- Container>>
+template <
+ class Container,
+ class From =
+ detail::CopiedSource<typename Container::value_type, Container>>
From from(Container&& source) {
return From(std::move(source));
}
-template<class Value, class Impl = detail::RangeImpl<Value>,
- class Gen = detail::Sequence<Value, Impl>>
+template <
+ class Value,
+ class Impl = detail::RangeImpl<Value>,
+ class Gen = detail::Sequence<Value, Impl>>
Gen range(Value begin, Value end) {
return Gen{std::move(begin), Impl{std::move(end)}};
}
-template<class Value, class Distance,
- class Impl = detail::RangeWithStepImpl<Value, Distance>,
- class Gen = detail::Sequence<Value, Impl>>
+template <
+ class Value,
+ class Distance,
+ class Impl = detail::RangeWithStepImpl<Value, Distance>,
+ class Gen = detail::Sequence<Value, Impl>>
Gen range(Value begin, Value end, Distance step) {
return Gen{std::move(begin), Impl{std::move(end), std::move(step)}};
}
-template<class Value, class Impl = detail::SeqImpl<Value>,
- class Gen = detail::Sequence<Value, Impl>>
+template <
+ class Value,
+ class Impl = detail::SeqImpl<Value>,
+ class Gen = detail::Sequence<Value, Impl>>
Gen seq(Value first, Value last) {
return Gen{std::move(first), Impl{std::move(last)}};
}
-template<class Value, class Distance,
- class Impl = detail::SeqWithStepImpl<Value, Distance>,
- class Gen = detail::Sequence<Value, Impl>>
+template <
+ class Value,
+ class Distance,
+ class Impl = detail::SeqWithStepImpl<Value, Distance>,
+ class Gen = detail::Sequence<Value, Impl>>
Gen seq(Value first, Value last, Distance step) {
return Gen{std::move(first), Impl{std::move(last), std::move(step)}};
}
-template<class Value, class Impl = detail::InfiniteImpl<Value>,
- class Gen = detail::Sequence<Value, Impl>>
+template <
+ class Value,
+ class Impl = detail::InfiniteImpl<Value>,
+ class Gen = detail::Sequence<Value, Impl>>
Gen seq(Value first) {
return Gen{std::move(first), Impl{}};
}
-template<class Value,
- class Source,
- class Yield = detail::Yield<Value, Source>>
+template <class Value, class Source, class Yield = detail::Yield<Value, Source>>
Yield generator(Source&& source) {
return Yield(std::forward<Source>(source));
}
/*
* Operator Factories
*/
-template<class Predicate,
- class Map = detail::Map<Predicate>>
+template <class Predicate, class Map = detail::Map<Predicate>>
Map mapped(Predicate pred = Predicate()) {
return Map(std::move(pred));
}
-template<class Predicate,
- class Map = detail::Map<Predicate>>
+template <class Predicate, class Map = detail::Map<Predicate>>
Map map(Predicate pred = Predicate()) {
return Map(std::move(pred));
}
* | mapOp(filter(sampleTest) | count)
* | sum;
*/
-template<class Operator,
- class Map = detail::Map<detail::Composer<Operator>>>
+template <class Operator, class Map = detail::Map<detail::Composer<Operator>>>
Map mapOp(Operator op) {
return Map(detail::Composer<Operator>(std::move(op)));
}
* assignment and comparisons don't work properly without being pulled out
* of the template declaration
*/
-template <MemberType Constness> struct ExprIsConst {
+template <MemberType Constness>
+struct ExprIsConst {
enum {
value = Constness == Const
};
};
-template <MemberType Constness> struct ExprIsMutable {
+template <MemberType Constness>
+struct ExprIsMutable {
enum {
value = Constness == Mutable
};
};
-template<MemberType Constness = Const,
- class Class,
- class Return,
- class Mem = ConstMemberFunction<Class, Return>,
- class Map = detail::Map<Mem>>
+template <
+ MemberType Constness = Const,
+ class Class,
+ class Return,
+ class Mem = ConstMemberFunction<Class, Return>,
+ class Map = detail::Map<Mem>>
typename std::enable_if<ExprIsConst<Constness>::value, Map>::type
member(Return (Class::*member)() const) {
return Map(Mem(member));
}
-template<MemberType Constness = Mutable,
- class Class,
- class Return,
- class Mem = MemberFunction<Class, Return>,
- class Map = detail::Map<Mem>>
+template <
+ MemberType Constness = Mutable,
+ class Class,
+ class Return,
+ class Mem = MemberFunction<Class, Return>,
+ class Map = detail::Map<Mem>>
typename std::enable_if<ExprIsMutable<Constness>::value, Map>::type
member(Return (Class::*member)()) {
return Map(Mem(member));
* | field(&Item::name)
* | as<vector>();
*/
-template<class Class,
- class FieldType,
- class Field = Field<Class, FieldType>,
- class Map = detail::Map<Field>>
+template <
+ class Class,
+ class FieldType,
+ class Field = Field<Class, FieldType>,
+ class Map = detail::Map<Field>>
Map field(FieldType Class::*field) {
return Map(Field(field));
}
-template <class Predicate = Identity,
- class Filter = detail::Filter<Predicate>>
+template <class Predicate = Identity, class Filter = detail::Filter<Predicate>>
Filter filter(Predicate pred = Predicate()) {
return Filter(std::move(pred));
}
-template<class Predicate,
- class Until = detail::Until<Predicate>>
+template <class Predicate, class Until = detail::Until<Predicate>>
Until until(Predicate pred = Predicate()) {
return Until(std::move(pred));
}
-template<class Selector = Identity,
- class Comparer = Less,
- class Order = detail::Order<Selector, Comparer>>
+template <
+ class Selector = Identity,
+ class Comparer = Less,
+ class Order = detail::Order<Selector, Comparer>>
Order orderBy(Selector selector = Selector(),
Comparer comparer = Comparer()) {
return Order(std::move(selector),
std::move(comparer));
}
-template<class Selector = Identity,
- class Order = detail::Order<Selector, Greater>>
+template <
+ class Selector = Identity,
+ class Order = detail::Order<Selector, Greater>>
Order orderByDescending(Selector selector = Selector()) {
return Order(std::move(selector));
}
-template <class Selector = Identity,
- class GroupBy = detail::GroupBy<Selector>>
+template <class Selector = Identity, class GroupBy = detail::GroupBy<Selector>>
GroupBy groupBy(Selector selector = Selector()) {
return GroupBy(std::move(selector));
}
-template<class Selector = Identity,
- class Distinct = detail::Distinct<Selector>>
+template <
+ class Selector = Identity,
+ class Distinct = detail::Distinct<Selector>>
Distinct distinctBy(Selector selector = Selector()) {
return Distinct(std::move(selector));
}
-template<int n,
- class Get = detail::Map<Get<n>>>
+template <int n, class Get = detail::Map<Get<n>>>
Get get() {
return Get();
}
// construct Dest from each value
-template <class Dest,
- class Cast = detail::Map<Cast<Dest>>>
+template <class Dest, class Cast = detail::Map<Cast<Dest>>>
Cast eachAs() {
return Cast();
}
// call folly::to on each value
-template <class Dest,
- class To = detail::Map<To<Dest>>>
+template <class Dest, class To = detail::Map<To<Dest>>>
To eachTo() {
return To();
}
-template<class Value>
+template <class Value>
detail::TypeAssertion<Value> assert_type() {
return {};
}
* from(source) | any(pred) == from(source) | filter(pred) | notEmpty
*/
-template <class Predicate = Identity,
- class Filter = detail::Filter<Predicate>,
- class NotEmpty = detail::IsEmpty<false>,
- class Composed = detail::Composed<Filter, NotEmpty>>
+template <
+ class Predicate = Identity,
+ class Filter = detail::Filter<Predicate>,
+ class NotEmpty = detail::IsEmpty<false>,
+ class Composed = detail::Composed<Filter, NotEmpty>>
Composed any(Predicate pred = Predicate()) {
return Composed(Filter(std::move(pred)), NotEmpty());
}
* from(source) | all(pred) == from(source) | filter(negate(pred)) | isEmpty
*/
-template <class Predicate = Identity,
- class Filter = detail::Filter<Negate<Predicate>>,
- class IsEmpty = detail::IsEmpty<true>,
- class Composed = detail::Composed<Filter, IsEmpty>>
+template <
+ class Predicate = Identity,
+ class Filter = detail::Filter<Negate<Predicate>>,
+ class IsEmpty = detail::IsEmpty<true>,
+ class Composed = detail::Composed<Filter, IsEmpty>>
Composed all(Predicate pred = Predicate()) {
return Composed(Filter(std::move(negate(pred))), IsEmpty());
}
-template<class Seed,
- class Fold,
- class FoldLeft = detail::FoldLeft<Seed, Fold>>
+template <class Seed, class Fold, class FoldLeft = detail::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>>
+template <class Reducer, class Reduce = detail::Reduce<Reducer>>
Reduce reduce(Reducer reducer = Reducer()) {
return Reduce(std::move(reducer));
}
-template<class Selector = Identity,
- class Min = detail::Min<Selector, Less>>
+template <class Selector = Identity, class Min = detail::Min<Selector, Less>>
Min minBy(Selector selector = Selector()) {
return Min(std::move(selector));
}
-template<class Selector,
- class MaxBy = detail::Min<Selector, Greater>>
+template <class Selector, class MaxBy = detail::Min<Selector, Greater>>
MaxBy maxBy(Selector selector = Selector()) {
return MaxBy(std::move(selector));
}
-template<class Collection,
- class Collect = detail::Collect<Collection>>
+template <class Collection, class Collect = detail::Collect<Collection>>
Collect as() {
return Collect();
}
-template<template<class, class> class Container = std::vector,
- template<class> class Allocator = std::allocator,
- class Collect = detail::CollectTemplate<Container, Allocator>>
+template <
+ template <class, class> class Container = std::vector,
+ template <class> class Allocator = std::allocator,
+ class Collect = detail::CollectTemplate<Container, Allocator>>
Collect as() {
return Collect();
}
-template<class Collection,
- class Append = detail::Append<Collection>>
+template <class Collection, class Append = detail::Append<Collection>>
Append appendTo(Collection& collection) {
return Append(&collection);
}
-template<class Needle,
- class Contains = detail::Contains<typename std::decay<Needle>::type>>
+template <
+ class Needle,
+ class Contains = detail::Contains<typename std::decay<Needle>::type>>
Contains contains(Needle&& needle) {
return Contains(std::forward<Needle>(needle));
}
-template<class Exception,
- class ErrorHandler,
- class GuardImpl =
- detail::GuardImpl<
- Exception,
- typename std::decay<ErrorHandler>::type>>
+template <
+ class Exception,
+ class ErrorHandler,
+ class GuardImpl =
+ detail::GuardImpl<Exception, typename std::decay<ErrorHandler>::type>>
GuardImpl guard(ErrorHandler&& handler) {
return GuardImpl(std::forward<ErrorHandler>(handler));
}
-template<class Fallback,
- class UnwrapOr = detail::UnwrapOr<typename std::decay<Fallback>::type>>
+template <
+ class Fallback,
+ class UnwrapOr = detail::UnwrapOr<typename std::decay<Fallback>::type>>
UnwrapOr unwrapOr(Fallback&& fallback) {
return UnwrapOr(std::forward<Fallback>(fallback));
}
* Alternate values from a sequence with values from a sequence container.
* Stops once we run out of values from either source.
*/
-template<class Container>
+template <class Container>
class Interleave : public Operator<Interleave<Container>> {
// see comment about copies in CopiedSource
const std::shared_ptr<const Container> container_;
explicit Interleave(Container container)
: container_(new Container(std::move(container))) {}
- template<class Value,
- class Source>
+ template <class Value, class Source>
class Generator : public GenImpl<Value, Generator<Value, Source>> {
Source source_;
const std::shared_ptr<const Container> container_;
: source_(std::move(source)),
container_(container) { }
- template<class Handler>
+ template <class Handler>
bool apply(Handler&& handler) const {
auto iter = container_->begin();
return source_.apply([&](const Value& value) -> bool {
}
};
- template<class Value2,
- class Source,
- class Gen = Generator<Value2,Source>>
+ template <class Value2, class Source, class Gen = Generator<Value2, Source>>
Gen compose(GenImpl<Value2, Source>&& source) const {
return Gen(std::move(source.self()), container_);
}
- template<class Value2,
- class Source,
- class Gen = Generator<Value2,Source>>
+ template <class Value2, class Source, class Gen = Generator<Value2, Source>>
Gen compose(const GenImpl<Value2, Source>& source) const {
return Gen(source.self(), container_);
}
* them into a tuple.
*
*/
-template<class Container>
+template <class Container>
class Zip : public Operator<Zip<Container>> {
// see comment about copies in CopiedSource
const std::shared_ptr<const Container> container_;
explicit Zip(Container container)
: container_(new Container(std::move(container))) {}
- template<class Value1,
- class Source,
- class Value2 = decltype(*std::begin(*container_)),
- class Result = std::tuple<typename std::decay<Value1>::type,
- typename std::decay<Value2>::type>>
+ template <
+ class Value1,
+ class Source,
+ class Value2 = decltype(*std::begin(*container_)),
+ class Result = std::tuple<
+ typename std::decay<Value1>::type,
+ typename std::decay<Value2>::type>>
class Generator : public GenImpl<Result,
Generator<Value1,Source,Value2,Result>> {
Source source_;
: source_(std::move(source)),
container_(container) { }
- template<class Handler>
+ template <class Handler>
bool apply(Handler&& handler) const {
auto iter = container_->begin();
return (source_.apply([&](Value1 value) -> bool {
}
};
- template<class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), container_);
}
- template<class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), container_);
}
};
-template<class... Types1,
- class... Types2>
+template <class... Types1, class... Types2>
auto add_to_tuple(std::tuple<Types1...> t1, std::tuple<Types2...> t2) ->
std::tuple<Types1..., Types2...> {
return std::tuple_cat(std::move(t1), std::move(t2));
}
-template<class... Types1,
- class Type2>
+template <class... Types1, class Type2>
auto add_to_tuple(std::tuple<Types1...> t1, Type2&& t2) ->
decltype(std::tuple_cat(std::move(t1),
std::make_tuple(std::forward<Type2>(t2)))) {
std::make_tuple(std::forward<Type2>(t2)));
}
-template<class Type1,
- class... Types2>
+template <class Type1, class... Types2>
auto add_to_tuple(Type1&& t1, std::tuple<Types2...> t2) ->
decltype(std::tuple_cat(std::make_tuple(std::forward<Type1>(t1)),
std::move(t2))) {
std::move(t2));
}
-template<class Type1,
- class Type2>
+template <class Type1, class Type2>
auto add_to_tuple(Type1&& t1, Type2&& t2) ->
decltype(std::make_tuple(std::forward<Type1>(t1),
std::forward<Type2>(t2))) {
// Merges a 2-tuple into a single tuple (get<0> could already be a tuple)
class MergeTuples {
public:
- template<class Tuple>
+ template <class Tuple>
auto operator()(Tuple&& value) const ->
decltype(add_to_tuple(std::get<0>(std::forward<Tuple>(value)),
std::get<1>(std::forward<Tuple>(value)))) {
// TODO(mcurtiss): support zip() for N>1 operands. Because of variadic problems,
// this might not be easily possible until gcc4.8 is available.
-template<class Source,
- class Zip = detail::Zip<typename std::decay<Source>::type>>
+template <
+ class Source,
+ class Zip = detail::Zip<typename std::decay<Source>::type>>
Zip zip(Source&& source) {
return Zip(std::forward<Source>(source));
}
namespace gen {
namespace detail {
-template<class Container>
+template <class Container>
class Interleave;
-template<class Container>
+template <class Container>
class Zip;
} // namespace detail
-template<class Source2,
- class Source2Decayed = typename std::decay<Source2>::type,
- class Interleave = detail::Interleave<Source2Decayed>>
+template <
+ class Source2,
+ class Source2Decayed = typename std::decay<Source2>::type,
+ class Interleave = detail::Interleave<Source2Decayed>>
Interleave interleave(Source2&& source2) {
return Interleave(std::forward<Source2>(source2));
}
* Usage:
* IsCompatibleSignature<FunctorType, bool(int, float)>::value
*/
-template<class Candidate, class Expected>
+template <class Candidate, class Expected>
class IsCompatibleSignature {
static constexpr bool value = false;
};
-template<class Candidate,
- class ExpectedReturn,
- class... ArgTypes>
+template <class Candidate, class ExpectedReturn, class... ArgTypes>
class IsCompatibleSignature<Candidate, ExpectedReturn(ArgTypes...)> {
- template<class F,
- class ActualReturn =
- decltype(std::declval<F>()(std::declval<ArgTypes>()...)),
- bool good = std::is_same<ExpectedReturn, ActualReturn>::value>
+ template <
+ class F,
+ class ActualReturn =
+ decltype(std::declval<F>()(std::declval<ArgTypes>()...)),
+ bool good = std::is_same<ExpectedReturn, ActualReturn>::value>
static constexpr bool testArgs(int*) {
return good;
}
- template<class F>
+ template <class F>
static constexpr bool testArgs(...) {
return false;
}
* FBounded - Helper type for the curiously recurring template pattern, used
* heavily here to enable inlining and obviate virtual functions
*/
-template<class Self>
+template <class Self>
struct FBounded {
const Self& self() const {
return *static_cast<const Self*>(this);
* generator. All operators implement a method compose(), which takes a
* generator and produces an output generator.
*/
-template<class Self>
+template <class Self>
class Operator : public FBounded<Self> {
public:
/**
* compose() - Must be implemented by child class to compose a new Generator
* out of a given generator. This function left intentionally unimplemented.
*/
- template<class Source,
- class Value,
- class ResultGen = void>
+ template <class Source, class Value, class ResultGen = void>
ResultGen compose(const GenImpl<Value, Source>& source) const;
protected:
* operator|() - For composing two operators without binding it to a
* particular generator.
*/
-template<class Left,
- class Right,
- class Composed = detail::Composed<Left, Right>>
+template <
+ class Left,
+ class Right,
+ class Composed = detail::Composed<Left, Right>>
Composed operator|(const Operator<Left>& left,
const Operator<Right>& right) {
return Composed(left.self(), right.self());
}
-template<class Left,
- class Right,
- class Composed = detail::Composed<Left, Right>>
+template <
+ class Left,
+ class Right,
+ class Composed = detail::Composed<Left, Right>>
Composed operator|(const Operator<Left>& left,
Operator<Right>&& right) {
return Composed(left.self(), std::move(right.self()));
}
-template<class Left,
- class Right,
- class Composed = detail::Composed<Left, Right>>
+template <
+ class Left,
+ class Right,
+ class Composed = detail::Composed<Left, Right>>
Composed operator|(Operator<Left>&& left,
const Operator<Right>& right) {
return Composed(std::move(left.self()), right.self());
}
-template<class Left,
- class Right,
- class Composed = detail::Composed<Left, Right>>
+template <
+ class Left,
+ class Right,
+ class Composed = detail::Composed<Left, Right>>
Composed operator|(Operator<Left>&& left,
Operator<Right>&& right) {
return Composed(std::move(left.self()), std::move(right.self()));
* implement apply(). foreach() may also be implemented to special case the
* condition where the entire sequence is consumed.
*/
-template<class Value,
- class Self>
+template <class Value, class Self>
class GenImpl : public FBounded<Self> {
protected:
// To prevent slicing
* the handler returning false), as 'Chain' uses the return value of apply to
* determine if it should process the second object in its chain.
*/
- template<class Handler>
+ template <class Handler>
bool apply(Handler&& handler) const;
/**
* foreach() - Send all values produced by this generator to given lambda.
*/
- template<class Body>
+ template <class Body>
void foreach(Body&& body) const {
this->self().apply([&](Value value) -> bool {
static_assert(!infinite, "Cannot call foreach on infinite GenImpl");
static constexpr bool infinite = false;
};
-template<class LeftValue,
- class Left,
- class RightValue,
- class Right,
- class Chain = detail::Chain<LeftValue, Left, Right>>
+template <
+ class LeftValue,
+ class Left,
+ class RightValue,
+ class Right,
+ class Chain = detail::Chain<LeftValue, Left, Right>>
Chain operator+(const GenImpl<LeftValue, Left>& left,
const GenImpl<RightValue, Right>& right) {
static_assert(
return Chain(left.self(), right.self());
}
-template<class LeftValue,
- class Left,
- class RightValue,
- class Right,
- class Chain = detail::Chain<LeftValue, Left, Right>>
+template <
+ class LeftValue,
+ class Left,
+ class RightValue,
+ class Right,
+ class Chain = detail::Chain<LeftValue, Left, Right>>
Chain operator+(const GenImpl<LeftValue, Left>& left,
GenImpl<RightValue, Right>&& right) {
static_assert(
return Chain(left.self(), std::move(right.self()));
}
-template<class LeftValue,
- class Left,
- class RightValue,
- class Right,
- class Chain = detail::Chain<LeftValue, Left, Right>>
+template <
+ class LeftValue,
+ class Left,
+ class RightValue,
+ class Right,
+ class Chain = detail::Chain<LeftValue, Left, Right>>
Chain operator+(GenImpl<LeftValue, Left>&& left,
const GenImpl<RightValue, Right>& right) {
static_assert(
return Chain(std::move(left.self()), right.self());
}
-template<class LeftValue,
- class Left,
- class RightValue,
- class Right,
- class Chain = detail::Chain<LeftValue, Left, Right>>
+template <
+ class LeftValue,
+ class Left,
+ class RightValue,
+ class Right,
+ class Chain = detail::Chain<LeftValue, Left, Right>>
Chain operator+(GenImpl<LeftValue, Left>&& left,
GenImpl<RightValue, Right>&& right) {
static_assert(
* operator|() which enables foreach-like usage:
* gen | [](Value v) -> void {...};
*/
-template<class Value,
- class Gen,
- class Handler>
+template <class Value, class Gen, class Handler>
typename std::enable_if<
IsCompatibleSignature<Handler, void(Value)>::value>::type
operator|(const GenImpl<Value, Gen>& gen, Handler&& handler) {
* operator|() which enables foreach-like usage with 'break' support:
* gen | [](Value v) -> bool { return shouldContinue(); };
*/
-template<class Value,
- class Gen,
- class Handler>
+template <class Value, class Gen, class Handler>
typename std::enable_if<
IsCompatibleSignature<Handler, bool(Value)>::value, bool>::type
operator|(const GenImpl<Value, Gen>& gen, Handler&& handler) {
* adaptors:
* gen | map(square) | sum
*/
-template<class Value,
- class Gen,
- class Op>
+template <class Value, class Gen, class Op>
auto operator|(const GenImpl<Value, Gen>& gen, const Operator<Op>& op) ->
decltype(op.self().compose(gen.self())) {
return op.self().compose(gen.self());
}
-template<class Value,
- class Gen,
- class Op>
+template <class Value, class Gen, class Op>
auto operator|(GenImpl<Value, Gen>&& gen, const Operator<Op>& op) ->
decltype(op.self().compose(std::move(gen.self()))) {
return op.self().compose(std::move(gen.self()));
*
* auto valuesIncluded = from(optionals) | valuesOf | as<vector>();
*/
-template<class First,
- class Second>
+template <class First, class Second>
class Composed : public Operator<Composed<First, Second>> {
First first_;
Second second_;
: first_(std::move(first))
, second_(std::move(second)) {}
- template<class Source,
- class Value,
- class FirstRet = decltype(std::declval<First>()
- .compose(std::declval<Source>())),
- class SecondRet = decltype(std::declval<Second>()
- .compose(std::declval<FirstRet>()))>
+ template <
+ class Source,
+ class Value,
+ class FirstRet =
+ decltype(std::declval<First>().compose(std::declval<Source>())),
+ class SecondRet =
+ decltype(std::declval<Second>().compose(std::declval<FirstRet>()))>
SecondRet compose(const GenImpl<Value, Source>& source) const {
return second_.compose(first_.compose(source.self()));
}
- template<class Source,
- class Value,
- class FirstRet = decltype(std::declval<First>()
- .compose(std::declval<Source>())),
- class SecondRet = decltype(std::declval<Second>()
- .compose(std::declval<FirstRet>()))>
+ template <
+ class Source,
+ class Value,
+ class FirstRet =
+ decltype(std::declval<First>().compose(std::declval<Source>())),
+ class SecondRet =
+ decltype(std::declval<Second>().compose(std::declval<FirstRet>()))>
SecondRet compose(GenImpl<Value, Source>&& source) const {
return second_.compose(first_.compose(std::move(source.self())));
}
* auto nums = seq(1, 10) + seq(20, 30);
* int total = nums | sum;
*/
-template<class Value, class First, class Second>
+template <class Value, class First, class Second>
class Chain : public GenImpl<Value,
Chain<Value, First, Second>> {
First first_;
: first_(std::move(first))
, second_(std::move(second)) {}
- template<class Handler>
+ template <class Handler>
bool apply(Handler&& handler) const {
return first_.apply(std::forward<Handler>(handler))
&& second_.apply(std::forward<Handler>(handler));
}
- template<class Body>
+ template <class Body>
void foreach(Body&& body) const {
first_.foreach(std::forward<Body>(body));
second_.foreach(std::forward<Body>(body));
namespace folly {
namespace gen {
-template<class Value, class Self>
+template <class Value, class Self>
class GenImpl;
-template<class Self>
+template <class Self>
class Operator;
namespace detail {
-template<class Self>
+template <class Self>
struct FBounded;
-template<class First, class Second>
+template <class First, class Second>
class Composed;
-template<class Value, class First, class Second>
+template <class Value, class First, class Second>
class Chain;
} // detail
public:
explicit Sub(Sink sink) : sink_(sink) {}
- template <class Value,
- class Source,
- class Result =
- decltype(std::declval<Sink>().compose(std::declval<Source>())),
- class Just = SingleCopy<typename std::decay<Result>::type>>
+ template <
+ class Value,
+ class Source,
+ class Result =
+ decltype(std::declval<Sink>().compose(std::declval<Source>())),
+ class Just = SingleCopy<typename std::decay<Result>::type>>
Just compose(const GenImpl<Value, Source>& source) const {
return Just(source | sink_);
}
public:
Parallel(Ops ops, size_t threads) : ops_(std::move(ops)), threads_(threads) {}
- template <class Input,
- class Source,
- class InputDecayed = typename std::decay<Input>::type,
- class Composed =
- decltype(std::declval<Ops>().compose(Empty<InputDecayed&&>())),
- class Output = typename Composed::ValueType,
- class OutputDecayed = typename std::decay<Output>::type>
+ template <
+ class Input,
+ class Source,
+ class InputDecayed = typename std::decay<Input>::type,
+ class Composed =
+ decltype(std::declval<Ops>().compose(Empty<InputDecayed&&>())),
+ class Output = typename Composed::ValueType,
+ class OutputDecayed = typename std::decay<Output>::type>
class Generator : public GenImpl<OutputDecayed&&,
Generator<Input,
Source,
* Especially for use with 'parallel()', chunked can be used to process values
* from a persistent container in chunks larger than one value at a time. The
* values produced are generators for slices of the input container. */
-template <class Container,
- class Iterator = typename Container::const_iterator,
- class Chunked = detail::ChunkedRangeSource<Iterator>>
+template <
+ class Container,
+ class Iterator = typename Container::const_iterator,
+ class Chunked = detail::ChunkedRangeSource<Iterator>>
Chunked chunked(const Container& container, int chunkSize = 256) {
return Chunked(chunkSize, folly::range(container.begin(), container.end()));
}
-template <class Container,
- class Iterator = typename Container::iterator,
- class Chunked = detail::ChunkedRangeSource<Iterator>>
+template <
+ class Container,
+ class Iterator = typename Container::iterator,
+ class Chunked = detail::ChunkedRangeSource<Iterator>>
Chunked chunked(Container& container, int chunkSize = 256) {
return Chunked(chunkSize, folly::range(container.begin(), container.end()));
}
*
* auto squares = seq(1, 10) | pmap(fibonacci, 4) | sum;
*/
-template<class Predicate>
+template <class Predicate>
class PMap : public Operator<PMap<Predicate>> {
Predicate pred_;
size_t nThreads_;
: pred_(std::move(pred)),
nThreads_(nThreads) { }
- template<class Value,
- class Source,
- class Input = typename std::decay<Value>::type,
- class Output = typename std::decay<
- typename std::result_of<Predicate(Value)>::type
- >::type>
+ template <
+ class Value,
+ class Source,
+ class Input = typename std::decay<Value>::type,
+ class Output = typename std::decay<
+ typename std::result_of<Predicate(Value)>::type>::type>
class Generator :
public GenImpl<Output, Generator<Value, Source, Input, Output>> {
Source source_;
nThreads_(nThreads ? nThreads : sysconf(_SC_NPROCESSORS_ONLN)) {
}
- template<class Body>
+ template <class Body>
void foreach(Body&& body) const {
ExecutionPipeline pipeline(pred_, nThreads_);
}
}
- template<class Handler>
+ template <class Handler>
bool apply(Handler&& handler) const {
ExecutionPipeline pipeline(pred_, nThreads_);
static constexpr bool infinite = Source::infinite;
};
- template<class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), pred_, nThreads_);
}
- template<class Source,
- class Value,
- class Gen = Generator<Value, Source>>
+ template <class Source, class Value, class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), pred_, nThreads_);
}
namespace detail {
-template<class Predicate>
+template <class Predicate>
class PMap;
} // namespace detail
* generator and the rest of the pipeline is executed in the
* caller thread.
*/
-template<class Predicate,
- class PMap = detail::PMap<Predicate>>
+template <class Predicate, class PMap = detail::PMap<Predicate>>
PMap pmap(Predicate pred = Predicate(), size_t nThreads = 0) {
return PMap(std::move(pred), nThreads);
}
static constexpr bool infinite = Source::infinite;
};
- template<class Source,
- class Value,
- class Gen = Generator<Source>>
+ template <class Source, class Value, class Gen = Generator<Source>>
Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), delimiter_, keepDelimiter_);
}
- template<class Source,
- class Value,
- class Gen = Generator<Source>>
+ template <class Source, class Value, class Gen = Generator<Source>>
Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), delimiter_, keepDelimiter_);
}
*
* This type is primarily used through the 'unsplit' function.
*/
-template<class Delimiter,
- class Output>
+template <class Delimiter, class Output>
class Unsplit : public Operator<Unsplit<Delimiter, Output>> {
Delimiter delimiter_;
public:
: delimiter_(delimiter) {
}
- template<class Source,
- class Value>
+ template <class Source, class Value>
Output compose(const GenImpl<Value, Source>& source) const {
Output outputBuffer;
UnsplitBuffer<Delimiter, Output> unsplitter(delimiter_, &outputBuffer);
*
* This type is primarily used through the 'unsplit' function.
*/
-template<class Delimiter,
- class OutputBuffer>
+template <class Delimiter, class OutputBuffer>
class UnsplitBuffer : public Operator<UnsplitBuffer<Delimiter, OutputBuffer>> {
Delimiter delimiter_;
OutputBuffer* outputBuffer_;
CHECK(outputBuffer);
}
- template<class Source,
- class Value>
+ template <class Source, class Value>
void compose(const GenImpl<Value, Source>& source) const {
// If the output buffer is empty, we skip inserting the delimiter for the
// first element.
/**
* Hack for static for-like constructs
*/
-template<class Target, class=void>
+template <class Target, class = void>
inline Target passthrough(Target target) { return target; }
FOLLY_PUSH_WARNING
* | as<vector<tuple<int, string>>>();
*
*/
-template<class TargetContainer,
- class Delimiter,
- class... Targets>
+template <class TargetContainer, class Delimiter, class... Targets>
class SplitTo {
Delimiter delimiter_;
public:
namespace detail {
class StringResplitter;
-template<class Delimiter>
+template <class Delimiter>
class SplitStringSource;
-template<class Delimiter, class Output>
+template <class Delimiter, class Output>
class Unsplit;
-template<class Delimiter, class OutputBuffer>
+template <class Delimiter, class OutputBuffer>
class UnsplitBuffer;
-template<class TargetContainer,
- class Delimiter,
- class... Targets>
+template <class TargetContainer, class Delimiter, class... Targets>
class SplitTo;
} // namespace detail
// NOTE: The template arguments are reversed to allow the user to cleanly
// specify the output type while still inferring the type of the delimiter.
-template<class Output = folly::fbstring,
- class Delimiter,
- class Unsplit = detail::Unsplit<Delimiter, Output>>
+template <
+ class Output = folly::fbstring,
+ class Delimiter,
+ class Unsplit = detail::Unsplit<Delimiter, Output>>
Unsplit unsplit(const Delimiter& delimiter) {
return Unsplit(delimiter);
}
-template<class Output = folly::fbstring,
- class Unsplit = detail::Unsplit<fbstring, Output>>
+template <
+ class Output = folly::fbstring,
+ class Unsplit = detail::Unsplit<fbstring, Output>>
Unsplit unsplit(const char* delimiter) {
return Unsplit(delimiter);
}
* split("a,b,c", ",") | unsplit(",", &anotherbuffer);
* assert(anotherBuffer == "initial,a,b,c");
*/
-template<class Delimiter,
- class OutputBuffer,
- class UnsplitBuffer = detail::UnsplitBuffer<Delimiter, OutputBuffer>>
+template <
+ class Delimiter,
+ class OutputBuffer,
+ class UnsplitBuffer = detail::UnsplitBuffer<Delimiter, OutputBuffer>>
UnsplitBuffer unsplit(Delimiter delimiter, OutputBuffer* outputBuffer) {
return UnsplitBuffer(delimiter, outputBuffer);
}
-template<class OutputBuffer,
- class UnsplitBuffer = detail::UnsplitBuffer<fbstring, OutputBuffer>>
+template <
+ class OutputBuffer,
+ class UnsplitBuffer = detail::UnsplitBuffer<fbstring, OutputBuffer>>
UnsplitBuffer unsplit(const char* delimiter, OutputBuffer* outputBuffer) {
return UnsplitBuffer(delimiter, outputBuffer);
}
-
-template<class... Targets>
+template <class... Targets>
detail::Map<detail::SplitTo<std::tuple<Targets...>, char, Targets...>>
eachToTuple(char delim) {
return detail::Map<
detail::SplitTo<std::tuple<Targets...>, char, Targets...>(delim));
}
-template<class... Targets>
+template <class... Targets>
detail::Map<detail::SplitTo<std::tuple<Targets...>, fbstring, Targets...>>
eachToTuple(StringPiece delim) {
return detail::Map<
detail::SplitTo<std::tuple<Targets...>, fbstring, Targets...>(delim));
}
-template<class First, class Second>
+template <class First, class Second>
detail::Map<detail::SplitTo<std::pair<First, Second>, char, First, Second>>
eachToPair(char delim) {
return detail::Map<
detail::SplitTo<std::pair<First, Second>, char, First, Second>(delim));
}
-template<class First, class Second>
+template <class First, class Second>
detail::Map<detail::SplitTo<std::pair<First, Second>, fbstring, First, Second>>
eachToPair(StringPiece delim) {
return detail::Map<
}
struct FibYielder {
- template<class Yield>
+ template <class Yield>
void operator()(Yield&& yield) const {
int a = 0;
int b = 1;
EXPECT_SAME(const int&, typename ArgumentReference<const int&>::type);
EXPECT_SAME(const int&, typename ArgumentReference<const int>::type);
-template<typename T>
+template <typename T>
ostream& operator<<(ostream& os, const set<T>& values) {
return os << from(values);
}
-template<typename T>
+template <typename T>
ostream& operator<<(ostream& os, const vector<T>& values) {
os << "[";
for (auto& value : values) {
auto product = foldl(1, multiply);
-template<typename A, typename B>
+template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& pair) {
return os << "(" << pair.first << ", " << pair.second << ")";
}
};
struct {
- template<class T>
+ template <class T>
std::unique_ptr<T> operator()(T t) const {
return std::unique_ptr<T>(new T(std::move(t)));
}
);
}
-template<typename F>
+template <typename F>
void runUnsplitSuite(F fn) {
fn("hello, world");
fn("hello,world,goodbye");