Commit adb8559d authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Apply clang-format to folly/gen/ (template decls)

Summary: [Folly] Apply `clang-format` to `folly/gen/` (template decls).

Reviewed By: Orvid

Differential Revision: D5216229

fbshipit-source-id: 1659f1944ccde4de39bccd189bb6490395cf29c2
parent 1b0c0d91
This diff is collapsed.
This diff is collapsed.
...@@ -33,7 +33,7 @@ namespace detail { ...@@ -33,7 +33,7 @@ namespace detail {
* Alternate values from a sequence with values from a sequence container. * Alternate values from a sequence with values from a sequence container.
* Stops once we run out of values from either source. * Stops once we run out of values from either source.
*/ */
template<class Container> template <class Container>
class Interleave : public Operator<Interleave<Container>> { class Interleave : public Operator<Interleave<Container>> {
// see comment about copies in CopiedSource // see comment about copies in CopiedSource
const std::shared_ptr<const Container> container_; const std::shared_ptr<const Container> container_;
...@@ -41,8 +41,7 @@ class Interleave : public Operator<Interleave<Container>> { ...@@ -41,8 +41,7 @@ class Interleave : public Operator<Interleave<Container>> {
explicit Interleave(Container container) explicit Interleave(Container container)
: container_(new Container(std::move(container))) {} : container_(new Container(std::move(container))) {}
template<class Value, template <class Value, class Source>
class Source>
class Generator : public GenImpl<Value, Generator<Value, Source>> { class Generator : public GenImpl<Value, Generator<Value, Source>> {
Source source_; Source source_;
const std::shared_ptr<const Container> container_; const std::shared_ptr<const Container> container_;
...@@ -56,7 +55,7 @@ class Interleave : public Operator<Interleave<Container>> { ...@@ -56,7 +55,7 @@ class Interleave : public Operator<Interleave<Container>> {
: source_(std::move(source)), : source_(std::move(source)),
container_(container) { } container_(container) { }
template<class Handler> template <class Handler>
bool apply(Handler&& handler) const { bool apply(Handler&& handler) const {
auto iter = container_->begin(); auto iter = container_->begin();
return source_.apply([&](const Value& value) -> bool { return source_.apply([&](const Value& value) -> bool {
...@@ -75,16 +74,12 @@ class Interleave : public Operator<Interleave<Container>> { ...@@ -75,16 +74,12 @@ class Interleave : public Operator<Interleave<Container>> {
} }
}; };
template<class Value2, template <class Value2, class Source, class Gen = Generator<Value2, Source>>
class Source,
class Gen = Generator<Value2,Source>>
Gen compose(GenImpl<Value2, Source>&& source) const { Gen compose(GenImpl<Value2, Source>&& source) const {
return Gen(std::move(source.self()), container_); return Gen(std::move(source.self()), container_);
} }
template<class Value2, template <class Value2, class Source, class Gen = Generator<Value2, Source>>
class Source,
class Gen = Generator<Value2,Source>>
Gen compose(const GenImpl<Value2, Source>& source) const { Gen compose(const GenImpl<Value2, Source>& source) const {
return Gen(source.self(), container_); return Gen(source.self(), container_);
} }
...@@ -97,7 +92,7 @@ class Interleave : public Operator<Interleave<Container>> { ...@@ -97,7 +92,7 @@ class Interleave : public Operator<Interleave<Container>> {
* them into a tuple. * them into a tuple.
* *
*/ */
template<class Container> template <class Container>
class Zip : public Operator<Zip<Container>> { class Zip : public Operator<Zip<Container>> {
// see comment about copies in CopiedSource // see comment about copies in CopiedSource
const std::shared_ptr<const Container> container_; const std::shared_ptr<const Container> container_;
...@@ -105,11 +100,13 @@ class Zip : public Operator<Zip<Container>> { ...@@ -105,11 +100,13 @@ class Zip : public Operator<Zip<Container>> {
explicit Zip(Container container) explicit Zip(Container container)
: container_(new Container(std::move(container))) {} : container_(new Container(std::move(container))) {}
template<class Value1, template <
class Source, class Value1,
class Value2 = decltype(*std::begin(*container_)), class Source,
class Result = std::tuple<typename std::decay<Value1>::type, class Value2 = decltype(*std::begin(*container_)),
typename std::decay<Value2>::type>> class Result = std::tuple<
typename std::decay<Value1>::type,
typename std::decay<Value2>::type>>
class Generator : public GenImpl<Result, class Generator : public GenImpl<Result,
Generator<Value1,Source,Value2,Result>> { Generator<Value1,Source,Value2,Result>> {
Source source_; Source source_;
...@@ -120,7 +117,7 @@ class Zip : public Operator<Zip<Container>> { ...@@ -120,7 +117,7 @@ class Zip : public Operator<Zip<Container>> {
: source_(std::move(source)), : source_(std::move(source)),
container_(container) { } container_(container) { }
template<class Handler> template <class Handler>
bool apply(Handler&& handler) const { bool apply(Handler&& handler) const {
auto iter = container_->begin(); auto iter = container_->begin();
return (source_.apply([&](Value1 value) -> bool { return (source_.apply([&](Value1 value) -> bool {
...@@ -136,30 +133,24 @@ class Zip : public Operator<Zip<Container>> { ...@@ -136,30 +133,24 @@ class Zip : public Operator<Zip<Container>> {
} }
}; };
template<class Source, template <class Source, class Value, class Gen = Generator<Value, Source>>
class Value,
class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const { Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), container_); return Gen(std::move(source.self()), container_);
} }
template<class Source, template <class Source, class Value, class Gen = Generator<Value, Source>>
class Value,
class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const { Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), container_); return Gen(source.self(), container_);
} }
}; };
template<class... Types1, template <class... Types1, class... Types2>
class... Types2>
auto add_to_tuple(std::tuple<Types1...> t1, std::tuple<Types2...> t2) -> auto add_to_tuple(std::tuple<Types1...> t1, std::tuple<Types2...> t2) ->
std::tuple<Types1..., Types2...> { std::tuple<Types1..., Types2...> {
return std::tuple_cat(std::move(t1), std::move(t2)); return std::tuple_cat(std::move(t1), std::move(t2));
} }
template<class... Types1, template <class... Types1, class Type2>
class Type2>
auto add_to_tuple(std::tuple<Types1...> t1, Type2&& t2) -> auto add_to_tuple(std::tuple<Types1...> t1, Type2&& t2) ->
decltype(std::tuple_cat(std::move(t1), decltype(std::tuple_cat(std::move(t1),
std::make_tuple(std::forward<Type2>(t2)))) { std::make_tuple(std::forward<Type2>(t2)))) {
...@@ -167,8 +158,7 @@ decltype(std::tuple_cat(std::move(t1), ...@@ -167,8 +158,7 @@ decltype(std::tuple_cat(std::move(t1),
std::make_tuple(std::forward<Type2>(t2))); std::make_tuple(std::forward<Type2>(t2)));
} }
template<class Type1, template <class Type1, class... Types2>
class... Types2>
auto add_to_tuple(Type1&& t1, std::tuple<Types2...> t2) -> auto add_to_tuple(Type1&& t1, std::tuple<Types2...> t2) ->
decltype(std::tuple_cat(std::make_tuple(std::forward<Type1>(t1)), decltype(std::tuple_cat(std::make_tuple(std::forward<Type1>(t1)),
std::move(t2))) { std::move(t2))) {
...@@ -176,8 +166,7 @@ decltype(std::tuple_cat(std::make_tuple(std::forward<Type1>(t1)), ...@@ -176,8 +166,7 @@ decltype(std::tuple_cat(std::make_tuple(std::forward<Type1>(t1)),
std::move(t2)); std::move(t2));
} }
template<class Type1, template <class Type1, class Type2>
class Type2>
auto add_to_tuple(Type1&& t1, Type2&& t2) -> auto add_to_tuple(Type1&& t1, Type2&& t2) ->
decltype(std::make_tuple(std::forward<Type1>(t1), decltype(std::make_tuple(std::forward<Type1>(t1),
std::forward<Type2>(t2))) { std::forward<Type2>(t2))) {
...@@ -188,7 +177,7 @@ decltype(std::make_tuple(std::forward<Type1>(t1), ...@@ -188,7 +177,7 @@ decltype(std::make_tuple(std::forward<Type1>(t1),
// Merges a 2-tuple into a single tuple (get<0> could already be a tuple) // Merges a 2-tuple into a single tuple (get<0> could already be a tuple)
class MergeTuples { class MergeTuples {
public: public:
template<class Tuple> template <class Tuple>
auto operator()(Tuple&& value) const -> auto operator()(Tuple&& value) const ->
decltype(add_to_tuple(std::get<0>(std::forward<Tuple>(value)), decltype(add_to_tuple(std::get<0>(std::forward<Tuple>(value)),
std::get<1>(std::forward<Tuple>(value)))) { std::get<1>(std::forward<Tuple>(value)))) {
...@@ -205,8 +194,9 @@ class MergeTuples { ...@@ -205,8 +194,9 @@ class MergeTuples {
// TODO(mcurtiss): support zip() for N>1 operands. Because of variadic problems, // TODO(mcurtiss): support zip() for N>1 operands. Because of variadic problems,
// this might not be easily possible until gcc4.8 is available. // this might not be easily possible until gcc4.8 is available.
template<class Source, template <
class Zip = detail::Zip<typename std::decay<Source>::type>> class Source,
class Zip = detail::Zip<typename std::decay<Source>::type>>
Zip zip(Source&& source) { Zip zip(Source&& source) {
return Zip(std::forward<Source>(source)); return Zip(std::forward<Source>(source));
} }
......
...@@ -23,17 +23,18 @@ namespace folly { ...@@ -23,17 +23,18 @@ namespace folly {
namespace gen { namespace gen {
namespace detail { namespace detail {
template<class Container> template <class Container>
class Interleave; class Interleave;
template<class Container> template <class Container>
class Zip; class Zip;
} // namespace detail } // namespace detail
template<class Source2, template <
class Source2Decayed = typename std::decay<Source2>::type, class Source2,
class Interleave = detail::Interleave<Source2Decayed>> class Source2Decayed = typename std::decay<Source2>::type,
class Interleave = detail::Interleave<Source2Decayed>>
Interleave interleave(Source2&& source2) { Interleave interleave(Source2&& source2) {
return Interleave(std::forward<Source2>(source2)); return Interleave(std::forward<Source2>(source2));
} }
......
This diff is collapsed.
...@@ -20,21 +20,21 @@ ...@@ -20,21 +20,21 @@
namespace folly { namespace folly {
namespace gen { namespace gen {
template<class Value, class Self> template <class Value, class Self>
class GenImpl; class GenImpl;
template<class Self> template <class Self>
class Operator; class Operator;
namespace detail { namespace detail {
template<class Self> template <class Self>
struct FBounded; struct FBounded;
template<class First, class Second> template <class First, class Second>
class Composed; class Composed;
template<class Value, class First, class Second> template <class Value, class First, class Second>
class Chain; class Chain;
} // detail } // detail
......
...@@ -132,11 +132,12 @@ class Sub : public Operator<Sub<Sink>> { ...@@ -132,11 +132,12 @@ class Sub : public Operator<Sub<Sink>> {
public: public:
explicit Sub(Sink sink) : sink_(sink) {} explicit Sub(Sink sink) : sink_(sink) {}
template <class Value, template <
class Source, class Value,
class Result = class Source,
decltype(std::declval<Sink>().compose(std::declval<Source>())), class Result =
class Just = SingleCopy<typename std::decay<Result>::type>> decltype(std::declval<Sink>().compose(std::declval<Source>())),
class Just = SingleCopy<typename std::decay<Result>::type>>
Just compose(const GenImpl<Value, Source>& source) const { Just compose(const GenImpl<Value, Source>& source) const {
return Just(source | sink_); return Just(source | sink_);
} }
...@@ -150,13 +151,14 @@ class Parallel : public Operator<Parallel<Ops>> { ...@@ -150,13 +151,14 @@ class Parallel : public Operator<Parallel<Ops>> {
public: public:
Parallel(Ops ops, size_t threads) : ops_(std::move(ops)), threads_(threads) {} Parallel(Ops ops, size_t threads) : ops_(std::move(ops)), threads_(threads) {}
template <class Input, template <
class Source, class Input,
class InputDecayed = typename std::decay<Input>::type, class Source,
class Composed = class InputDecayed = typename std::decay<Input>::type,
decltype(std::declval<Ops>().compose(Empty<InputDecayed&&>())), class Composed =
class Output = typename Composed::ValueType, decltype(std::declval<Ops>().compose(Empty<InputDecayed&&>())),
class OutputDecayed = typename std::decay<Output>::type> class Output = typename Composed::ValueType,
class OutputDecayed = typename std::decay<Output>::type>
class Generator : public GenImpl<OutputDecayed&&, class Generator : public GenImpl<OutputDecayed&&,
Generator<Input, Generator<Input,
Source, Source,
......
...@@ -42,16 +42,18 @@ class ChunkedRangeSource; ...@@ -42,16 +42,18 @@ class ChunkedRangeSource;
* Especially for use with 'parallel()', chunked can be used to process values * 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 * from a persistent container in chunks larger than one value at a time. The
* values produced are generators for slices of the input container. */ * values produced are generators for slices of the input container. */
template <class Container, template <
class Iterator = typename Container::const_iterator, class Container,
class Chunked = detail::ChunkedRangeSource<Iterator>> class Iterator = typename Container::const_iterator,
class Chunked = detail::ChunkedRangeSource<Iterator>>
Chunked chunked(const Container& container, int chunkSize = 256) { Chunked chunked(const Container& container, int chunkSize = 256) {
return Chunked(chunkSize, folly::range(container.begin(), container.end())); return Chunked(chunkSize, folly::range(container.begin(), container.end()));
} }
template <class Container, template <
class Iterator = typename Container::iterator, class Container,
class Chunked = detail::ChunkedRangeSource<Iterator>> class Iterator = typename Container::iterator,
class Chunked = detail::ChunkedRangeSource<Iterator>>
Chunked chunked(Container& container, int chunkSize = 256) { Chunked chunked(Container& container, int chunkSize = 256) {
return Chunked(chunkSize, folly::range(container.begin(), container.end())); return Chunked(chunkSize, folly::range(container.begin(), container.end()));
} }
......
...@@ -42,7 +42,7 @@ namespace detail { ...@@ -42,7 +42,7 @@ namespace detail {
* *
* auto squares = seq(1, 10) | pmap(fibonacci, 4) | sum; * auto squares = seq(1, 10) | pmap(fibonacci, 4) | sum;
*/ */
template<class Predicate> template <class Predicate>
class PMap : public Operator<PMap<Predicate>> { class PMap : public Operator<PMap<Predicate>> {
Predicate pred_; Predicate pred_;
size_t nThreads_; size_t nThreads_;
...@@ -53,12 +53,12 @@ class PMap : public Operator<PMap<Predicate>> { ...@@ -53,12 +53,12 @@ class PMap : public Operator<PMap<Predicate>> {
: pred_(std::move(pred)), : pred_(std::move(pred)),
nThreads_(nThreads) { } nThreads_(nThreads) { }
template<class Value, template <
class Source, class Value,
class Input = typename std::decay<Value>::type, class Source,
class Output = typename std::decay< class Input = typename std::decay<Value>::type,
typename std::result_of<Predicate(Value)>::type class Output = typename std::decay<
>::type> typename std::result_of<Predicate(Value)>::type>::type>
class Generator : class Generator :
public GenImpl<Output, Generator<Value, Source, Input, Output>> { public GenImpl<Output, Generator<Value, Source, Input, Output>> {
Source source_; Source source_;
...@@ -153,7 +153,7 @@ class PMap : public Operator<PMap<Predicate>> { ...@@ -153,7 +153,7 @@ class PMap : public Operator<PMap<Predicate>> {
nThreads_(nThreads ? nThreads : sysconf(_SC_NPROCESSORS_ONLN)) { nThreads_(nThreads ? nThreads : sysconf(_SC_NPROCESSORS_ONLN)) {
} }
template<class Body> template <class Body>
void foreach(Body&& body) const { void foreach(Body&& body) const {
ExecutionPipeline pipeline(pred_, nThreads_); ExecutionPipeline pipeline(pred_, nThreads_);
...@@ -190,7 +190,7 @@ class PMap : public Operator<PMap<Predicate>> { ...@@ -190,7 +190,7 @@ class PMap : public Operator<PMap<Predicate>> {
} }
} }
template<class Handler> template <class Handler>
bool apply(Handler&& handler) const { bool apply(Handler&& handler) const {
ExecutionPipeline pipeline(pred_, nThreads_); ExecutionPipeline pipeline(pred_, nThreads_);
...@@ -238,16 +238,12 @@ class PMap : public Operator<PMap<Predicate>> { ...@@ -238,16 +238,12 @@ class PMap : public Operator<PMap<Predicate>> {
static constexpr bool infinite = Source::infinite; static constexpr bool infinite = Source::infinite;
}; };
template<class Source, template <class Source, class Value, class Gen = Generator<Value, Source>>
class Value,
class Gen = Generator<Value, Source>>
Gen compose(GenImpl<Value, Source>&& source) const { Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), pred_, nThreads_); return Gen(std::move(source.self()), pred_, nThreads_);
} }
template<class Source, template <class Source, class Value, class Gen = Generator<Value, Source>>
class Value,
class Gen = Generator<Value, Source>>
Gen compose(const GenImpl<Value, Source>& source) const { Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), pred_, nThreads_); return Gen(source.self(), pred_, nThreads_);
} }
......
...@@ -24,7 +24,7 @@ namespace gen { ...@@ -24,7 +24,7 @@ namespace gen {
namespace detail { namespace detail {
template<class Predicate> template <class Predicate>
class PMap; class PMap;
} // namespace detail } // namespace detail
...@@ -38,8 +38,7 @@ class PMap; ...@@ -38,8 +38,7 @@ class PMap;
* generator and the rest of the pipeline is executed in the * generator and the rest of the pipeline is executed in the
* caller thread. * caller thread.
*/ */
template<class Predicate, template <class Predicate, class PMap = detail::PMap<Predicate>>
class PMap = detail::PMap<Predicate>>
PMap pmap(Predicate pred = Predicate(), size_t nThreads = 0) { PMap pmap(Predicate pred = Predicate(), size_t nThreads = 0) {
return PMap(std::move(pred), nThreads); return PMap(std::move(pred), nThreads);
} }
......
...@@ -258,16 +258,12 @@ class StringResplitter : public Operator<StringResplitter> { ...@@ -258,16 +258,12 @@ class StringResplitter : public Operator<StringResplitter> {
static constexpr bool infinite = Source::infinite; static constexpr bool infinite = Source::infinite;
}; };
template<class Source, template <class Source, class Value, class Gen = Generator<Source>>
class Value,
class Gen = Generator<Source>>
Gen compose(GenImpl<Value, Source>&& source) const { Gen compose(GenImpl<Value, Source>&& source) const {
return Gen(std::move(source.self()), delimiter_, keepDelimiter_); return Gen(std::move(source.self()), delimiter_, keepDelimiter_);
} }
template<class Source, template <class Source, class Value, class Gen = Generator<Source>>
class Value,
class Gen = Generator<Source>>
Gen compose(const GenImpl<Value, Source>& source) const { Gen compose(const GenImpl<Value, Source>& source) const {
return Gen(source.self(), delimiter_, keepDelimiter_); return Gen(source.self(), delimiter_, keepDelimiter_);
} }
...@@ -309,8 +305,7 @@ class SplitStringSource ...@@ -309,8 +305,7 @@ class SplitStringSource
* *
* This type is primarily used through the 'unsplit' function. * This type is primarily used through the 'unsplit' function.
*/ */
template<class Delimiter, template <class Delimiter, class Output>
class Output>
class Unsplit : public Operator<Unsplit<Delimiter, Output>> { class Unsplit : public Operator<Unsplit<Delimiter, Output>> {
Delimiter delimiter_; Delimiter delimiter_;
public: public:
...@@ -318,8 +313,7 @@ class Unsplit : public Operator<Unsplit<Delimiter, Output>> { ...@@ -318,8 +313,7 @@ class Unsplit : public Operator<Unsplit<Delimiter, Output>> {
: delimiter_(delimiter) { : delimiter_(delimiter) {
} }
template<class Source, template <class Source, class Value>
class Value>
Output compose(const GenImpl<Value, Source>& source) const { Output compose(const GenImpl<Value, Source>& source) const {
Output outputBuffer; Output outputBuffer;
UnsplitBuffer<Delimiter, Output> unsplitter(delimiter_, &outputBuffer); UnsplitBuffer<Delimiter, Output> unsplitter(delimiter_, &outputBuffer);
...@@ -334,8 +328,7 @@ class Unsplit : public Operator<Unsplit<Delimiter, Output>> { ...@@ -334,8 +328,7 @@ class Unsplit : public Operator<Unsplit<Delimiter, Output>> {
* *
* This type is primarily used through the 'unsplit' function. * This type is primarily used through the 'unsplit' function.
*/ */
template<class Delimiter, template <class Delimiter, class OutputBuffer>
class OutputBuffer>
class UnsplitBuffer : public Operator<UnsplitBuffer<Delimiter, OutputBuffer>> { class UnsplitBuffer : public Operator<UnsplitBuffer<Delimiter, OutputBuffer>> {
Delimiter delimiter_; Delimiter delimiter_;
OutputBuffer* outputBuffer_; OutputBuffer* outputBuffer_;
...@@ -346,8 +339,7 @@ class UnsplitBuffer : public Operator<UnsplitBuffer<Delimiter, OutputBuffer>> { ...@@ -346,8 +339,7 @@ class UnsplitBuffer : public Operator<UnsplitBuffer<Delimiter, OutputBuffer>> {
CHECK(outputBuffer); CHECK(outputBuffer);
} }
template<class Source, template <class Source, class Value>
class Value>
void compose(const GenImpl<Value, Source>& source) const { void compose(const GenImpl<Value, Source>& source) const {
// If the output buffer is empty, we skip inserting the delimiter for the // If the output buffer is empty, we skip inserting the delimiter for the
// first element. // first element.
...@@ -367,7 +359,7 @@ class UnsplitBuffer : public Operator<UnsplitBuffer<Delimiter, OutputBuffer>> { ...@@ -367,7 +359,7 @@ class UnsplitBuffer : public Operator<UnsplitBuffer<Delimiter, OutputBuffer>> {
/** /**
* Hack for static for-like constructs * Hack for static for-like constructs
*/ */
template<class Target, class=void> template <class Target, class = void>
inline Target passthrough(Target target) { return target; } inline Target passthrough(Target target) { return target; }
FOLLY_PUSH_WARNING FOLLY_PUSH_WARNING
...@@ -386,9 +378,7 @@ FOLLY_PUSH_WARNING ...@@ -386,9 +378,7 @@ FOLLY_PUSH_WARNING
* | as<vector<tuple<int, string>>>(); * | as<vector<tuple<int, string>>>();
* *
*/ */
template<class TargetContainer, template <class TargetContainer, class Delimiter, class... Targets>
class Delimiter,
class... Targets>
class SplitTo { class SplitTo {
Delimiter delimiter_; Delimiter delimiter_;
public: public:
......
...@@ -27,18 +27,16 @@ namespace gen { ...@@ -27,18 +27,16 @@ namespace gen {
namespace detail { namespace detail {
class StringResplitter; class StringResplitter;
template<class Delimiter> template <class Delimiter>
class SplitStringSource; class SplitStringSource;
template<class Delimiter, class Output> template <class Delimiter, class Output>
class Unsplit; class Unsplit;
template<class Delimiter, class OutputBuffer> template <class Delimiter, class OutputBuffer>
class UnsplitBuffer; class UnsplitBuffer;
template<class TargetContainer, template <class TargetContainer, class Delimiter, class... Targets>
class Delimiter,
class... Targets>
class SplitTo; class SplitTo;
} // namespace detail } // namespace detail
...@@ -97,15 +95,17 @@ S lines(StringPiece source) { ...@@ -97,15 +95,17 @@ S lines(StringPiece source) {
// NOTE: The template arguments are reversed to allow the user to cleanly // NOTE: The template arguments are reversed to allow the user to cleanly
// specify the output type while still inferring the type of the delimiter. // specify the output type while still inferring the type of the delimiter.
template<class Output = folly::fbstring, template <
class Delimiter, class Output = folly::fbstring,
class Unsplit = detail::Unsplit<Delimiter, Output>> class Delimiter,
class Unsplit = detail::Unsplit<Delimiter, Output>>
Unsplit unsplit(const Delimiter& delimiter) { Unsplit unsplit(const Delimiter& delimiter) {
return Unsplit(delimiter); return Unsplit(delimiter);
} }
template<class Output = folly::fbstring, template <
class Unsplit = detail::Unsplit<fbstring, Output>> class Output = folly::fbstring,
class Unsplit = detail::Unsplit<fbstring, Output>>
Unsplit unsplit(const char* delimiter) { Unsplit unsplit(const char* delimiter) {
return Unsplit(delimiter); return Unsplit(delimiter);
} }
...@@ -124,21 +124,22 @@ Unsplit unsplit(const char* delimiter) { ...@@ -124,21 +124,22 @@ Unsplit unsplit(const char* delimiter) {
* split("a,b,c", ",") | unsplit(",", &anotherbuffer); * split("a,b,c", ",") | unsplit(",", &anotherbuffer);
* assert(anotherBuffer == "initial,a,b,c"); * assert(anotherBuffer == "initial,a,b,c");
*/ */
template<class Delimiter, template <
class OutputBuffer, class Delimiter,
class UnsplitBuffer = detail::UnsplitBuffer<Delimiter, OutputBuffer>> class OutputBuffer,
class UnsplitBuffer = detail::UnsplitBuffer<Delimiter, OutputBuffer>>
UnsplitBuffer unsplit(Delimiter delimiter, OutputBuffer* outputBuffer) { UnsplitBuffer unsplit(Delimiter delimiter, OutputBuffer* outputBuffer) {
return UnsplitBuffer(delimiter, outputBuffer); return UnsplitBuffer(delimiter, outputBuffer);
} }
template<class OutputBuffer, template <
class UnsplitBuffer = detail::UnsplitBuffer<fbstring, OutputBuffer>> class OutputBuffer,
class UnsplitBuffer = detail::UnsplitBuffer<fbstring, OutputBuffer>>
UnsplitBuffer unsplit(const char* delimiter, OutputBuffer* outputBuffer) { UnsplitBuffer unsplit(const char* delimiter, OutputBuffer* outputBuffer) {
return UnsplitBuffer(delimiter, outputBuffer); return UnsplitBuffer(delimiter, outputBuffer);
} }
template <class... Targets>
template<class... Targets>
detail::Map<detail::SplitTo<std::tuple<Targets...>, char, Targets...>> detail::Map<detail::SplitTo<std::tuple<Targets...>, char, Targets...>>
eachToTuple(char delim) { eachToTuple(char delim) {
return detail::Map< return detail::Map<
...@@ -146,7 +147,7 @@ eachToTuple(char delim) { ...@@ -146,7 +147,7 @@ eachToTuple(char delim) {
detail::SplitTo<std::tuple<Targets...>, char, Targets...>(delim)); detail::SplitTo<std::tuple<Targets...>, char, Targets...>(delim));
} }
template<class... Targets> template <class... Targets>
detail::Map<detail::SplitTo<std::tuple<Targets...>, fbstring, Targets...>> detail::Map<detail::SplitTo<std::tuple<Targets...>, fbstring, Targets...>>
eachToTuple(StringPiece delim) { eachToTuple(StringPiece delim) {
return detail::Map< return detail::Map<
...@@ -154,7 +155,7 @@ eachToTuple(StringPiece delim) { ...@@ -154,7 +155,7 @@ eachToTuple(StringPiece delim) {
detail::SplitTo<std::tuple<Targets...>, fbstring, Targets...>(delim)); 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>> detail::Map<detail::SplitTo<std::pair<First, Second>, char, First, Second>>
eachToPair(char delim) { eachToPair(char delim) {
return detail::Map< return detail::Map<
...@@ -162,7 +163,7 @@ eachToPair(char delim) { ...@@ -162,7 +163,7 @@ eachToPair(char delim) {
detail::SplitTo<std::pair<First, Second>, char, First, Second>(delim)); 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>> detail::Map<detail::SplitTo<std::pair<First, Second>, fbstring, First, Second>>
eachToPair(StringPiece delim) { eachToPair(StringPiece delim) {
return detail::Map< return detail::Map<
......
...@@ -174,7 +174,7 @@ BENCHMARK_RELATIVE(Fib_Sum_Gen, iters) { ...@@ -174,7 +174,7 @@ BENCHMARK_RELATIVE(Fib_Sum_Gen, iters) {
} }
struct FibYielder { struct FibYielder {
template<class Yield> template <class Yield>
void operator()(Yield&& yield) const { void operator()(Yield&& yield) const {
int a = 0; int a = 0;
int b = 1; int b = 1;
......
...@@ -48,12 +48,12 @@ EXPECT_SAME(int&, typename ArgumentReference<int&>::type); ...@@ -48,12 +48,12 @@ EXPECT_SAME(int&, typename ArgumentReference<int&>::type);
EXPECT_SAME(const int&, typename ArgumentReference<const int&>::type); EXPECT_SAME(const int&, typename ArgumentReference<const int&>::type);
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) { ostream& operator<<(ostream& os, const set<T>& values) {
return os << from(values); return os << from(values);
} }
template<typename T> template <typename T>
ostream& operator<<(ostream& os, const vector<T>& values) { ostream& operator<<(ostream& os, const vector<T>& values) {
os << "["; os << "[";
for (auto& value : values) { for (auto& value : values) {
...@@ -71,7 +71,7 @@ auto multiply = [](int a, int b) { return a * b; }; ...@@ -71,7 +71,7 @@ auto multiply = [](int a, int b) { return a * b; };
auto product = foldl(1, multiply); auto product = foldl(1, multiply);
template<typename A, typename B> template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& pair) { ostream& operator<<(ostream& os, const pair<A, B>& pair) {
return os << "(" << pair.first << ", " << pair.second << ")"; return os << "(" << pair.first << ", " << pair.second << ")";
} }
......
...@@ -50,7 +50,7 @@ static auto isPrime = [](int n) { ...@@ -50,7 +50,7 @@ static auto isPrime = [](int n) {
}; };
struct { struct {
template<class T> template <class T>
std::unique_ptr<T> operator()(T t) const { std::unique_ptr<T> operator()(T t) const {
return std::unique_ptr<T>(new T(std::move(t))); return std::unique_ptr<T>(new T(std::move(t)));
} }
......
...@@ -288,7 +288,7 @@ TEST(StringGen, ResplitMaxLength) { ...@@ -288,7 +288,7 @@ TEST(StringGen, ResplitMaxLength) {
); );
} }
template<typename F> template <typename F>
void runUnsplitSuite(F fn) { void runUnsplitSuite(F fn) {
fn("hello, world"); fn("hello, world");
fn("hello,world,goodbye"); fn("hello,world,goodbye");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment