Commit 802e8f7a authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

Tweak partial to avoid macos build failure

Summary:
[Folly] Tweak `partial` to avoid a poorly-understood build failure on macos with clang++ and libc++.

```
In file included from folly/functional/test/PartialTest.cpp:19:
In file included from folly/folly/Function.h:230:
folly/functional/Invoke.h:65:25: error: attempt to use a deleted function
      noexcept(noexcept(std::mem_fn(f)(static_cast<A&&>(a)...)))
                        ^
folly/functional/Partial.h:41:19: note: in instantiation of exception specification for 'operator()<int (int &, int &, int &), Foo, const Foo &, const int &, const int &, int &>' requested here
      -> decltype(invoke(
                  ^
folly/functional/Partial.h:65:56: note: while substituting deduced template arguments into function template 'invokeForward' [with Self = const folly::detail::partial::Partial<int (Foo::*)(int &, int &, int &), std::__1::tuple<Foo, int, int> > &, I = <0, 1, 2>, Args = <int &>]
  auto operator()(CArgs&&... cargs) const& -> decltype(invokeForward(
                                                       ^
folly/functional/test/PartialTest.cpp:59:21: note: while substituting deduced template arguments into function template 'operator()' [with CArgs = <int &>]
  EXPECT_EQ(1234, p0(four));
                    ^
type_traits:1743:5: note: '~__nat' has been explicitly marked deleted here
    ~__nat() = delete;
    ^
```

Reviewed By: chadaustin

Differential Revision: D23722804

fbshipit-source-id: 7b3d6307a46fa12eadea13db327f10aafb89691c
parent 7c35c2be
......@@ -31,17 +31,18 @@ namespace partial {
// not accidentally act as copy or move constructor
struct PartialConstructFromCallable {};
template <typename F, typename Tuple>
template <typename F, typename... StoredArg>
class Partial {
using Indexes = std::make_index_sequence<std::tuple_size<Tuple>{}>;
using Tuple = std::tuple<StoredArg...>;
using Indexes = std::index_sequence_for<StoredArg...>;
template <typename Self, std::size_t... I, typename... Args>
static auto
invokeForward(Self&& self, std::index_sequence<I...>, Args&&... args)
-> decltype(invoke(
std::declval<Self>().f_,
std::get<I>(std::declval<Self>().stored_args_)...,
std::declval<Args>()...)) {
-> invoke_result_t<
like_t<Self&&, F>,
like_t<Self&&, StoredArg>...,
Args&&...> {
return invoke(
std::forward<Self>(self).f_,
std::get<I>(std::forward<Self>(self).stored_args_)...,
......@@ -117,9 +118,9 @@ class Partial {
* and passed to the original callable.
*/
template <typename F, typename... Args>
auto partial(F&& f, Args&&... args) -> detail::partial::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<Args>::type...> {
return {detail::partial::PartialConstructFromCallable{},
std::forward<F>(f),
std::forward<Args>(args)...};
......
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