Commit 513fcbdf authored by Marshall Cline's avatar Marshall Cline Committed by Facebook Github Bot

Workaround gcc oddity with Future::within()

Summary:
Prior to this diff, the two `Future::within(Duration, Timekeeper* = nullptr)` overloads were the same typewise but they used different symbols:

Return-type differences:
* rvalue-qualified overload returned `Future<T>`
* lvalue-qualified overload returned `auto` (which resolved to `Future<T>`)

Parameter *name* differences:
* rvalue-qualified overload has unnamed formal-parameters (it is a declaration but not a definition).
* lvalue-qualified overload has named formal-parameters (it is both a declaration and a definition).

These seemingly innocuous differences caused gcc to choke: when the `this` object was a `Future<...>` object returned by value, gcc reported the following error: "error: call of overloaded ‘within(std::chrono::minutes)’ is ambiguous", specifically pointing to the two `Future::within(Duration, Timekeeper* = nullptr)` overloads.

Conversely clang had no problem with that callsite.

gcc stopped issuing the spurious error-message after this diff's changes, that is, after making the signatures of the two overloads identical in every respect except for the rvalue-qualification vs. lvalue-qualification.

Reviewed By: yfeldblum

Differential Revision: D9474736

fbshipit-source-id: 758001090e5487bd70c9853940807cbdeba8ac94
parent 55a896f5
......@@ -1541,9 +1541,9 @@ class Future : private futures::detail::FutureBase<T> {
/// - Calling code should act as if `valid() == false`,
/// i.e., as if `*this` was moved into RESULT.
/// - `RESULT.valid() == true`
Future<T> within(Duration, Timekeeper* = nullptr) &&;
Future<T> within(Duration dur, Timekeeper* tk = nullptr) &&;
auto within(Duration dur, Timekeeper* tk = nullptr) & {
Future<T> within(Duration dur, Timekeeper* tk = nullptr) & {
return std::move(*this).within(dur, tk);
}
......@@ -1561,10 +1561,10 @@ class Future : private futures::detail::FutureBase<T> {
/// i.e., as if `*this` was moved into RESULT.
/// - `RESULT.valid() == true`
template <class E>
Future<T> within(Duration, E exception, Timekeeper* = nullptr) &&;
Future<T> within(Duration dur, E exception, Timekeeper* tk = nullptr) &&;
template <class E>
auto within(Duration dur, E exception, Timekeeper* tk = nullptr) & {
Future<T> within(Duration dur, E exception, Timekeeper* tk = nullptr) & {
return std::move(*this).within(dur, exception, tk);
}
......
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