projects
/
folly.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
AsyncIO::cancel
[folly.git]
/
folly
/
Partial.h
diff --git
a/folly/Partial.h
b/folly/Partial.h
index 248a86a987a3f9be64bb52aa5e5eb2d4ba3a0af2..518e91ed673056d03ee4b1baa397d2b63dd6cf2d 100644
(file)
--- a/
folly/Partial.h
+++ b/
folly/Partial.h
@@
-1,5
+1,5
@@
/*
/*
- * Copyright 201
6
Facebook, Inc.
+ * Copyright 201
7
Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-20,6
+20,13
@@
namespace folly {
namespace folly {
+namespace detail {
+namespace partial {
+
+// helper type to make sure that the templated constructor in Partial does
+// not accidentally act as copy or move constructor
+struct PartialConstructFromCallable {};
+
template <typename F, typename Tuple>
class Partial {
private:
template <typename F, typename Tuple>
class Partial {
private:
@@
-28,7
+35,7
@@
class Partial {
public:
template <typename Callable, typename... Args>
public:
template <typename Callable, typename... Args>
- Partial(Callable&& callable, Args&&... args)
+ Partial(
PartialConstructFromCallable,
Callable&& callable, Args&&... args)
: f_(std::forward<Callable>(callable)),
stored_args_(std::forward<Args>(args)...) {}
: f_(std::forward<Callable>(callable)),
stored_args_(std::forward<Args>(args)...) {}
@@
-69,6
+76,9
@@
class Partial {
}
};
}
};
+} // namespace partial
+} // namespace detail
+
/**
* Partially applies arguments to a callable
*
/**
* Partially applies arguments to a callable
*
@@
-92,10
+102,12
@@
class Partial {
* and passed to the original callable.
*/
template <typename F, typename... Args>
* and passed to the original callable.
*/
template <typename F, typename... Args>
-auto partial(F&& f, Args&&... args) -> Partial<
+auto partial(F&& f, Args&&... args) ->
detail::partial::
Partial<
typename std::decay<F>::type,
std::tuple<typename std::decay<Args>::type...>> {
typename std::decay<F>::type,
std::tuple<typename std::decay<Args>::type...>> {
- return {std::forward<F>(f), std::forward<Args>(args)...};
+ return {detail::partial::PartialConstructFromCallable{},
+ std::forward<F>(f),
+ std::forward<Args>(args)...};
}
} // namespace folly
}
} // namespace folly