Commit ca0e432d authored by Andrew Krieger's avatar Andrew Krieger Committed by Facebook Github Bot

Workaround MSVC bug with referencing template constructors before definition

Summary:
MSVC has a bug where it is unable to match an out-of-line constructor (and
possibly other kind of member) to the definition if it is implicitly referenced
before the definition is processed. The guilty method is
SemiFuture<Unit> makeSemiFuture(). Moving it after the constructor definitions
resolves the issue.

Reviewed By: yfeldblum

Differential Revision: D6042277

fbshipit-source-id: 97fe97c0edf3df3d9e3b808968b450c73959b600
parent dbf0c410
...@@ -136,10 +136,6 @@ SemiFuture<typename std::decay<T>::type> makeSemiFuture(T&& t) { ...@@ -136,10 +136,6 @@ SemiFuture<typename std::decay<T>::type> makeSemiFuture(T&& t) {
return makeSemiFuture(Try<typename std::decay<T>::type>(std::forward<T>(t))); return makeSemiFuture(Try<typename std::decay<T>::type>(std::forward<T>(t)));
} }
inline SemiFuture<Unit> makeSemiFuture() {
return makeSemiFuture(Unit{});
}
// makeSemiFutureWith(SemiFuture<T>()) -> SemiFuture<T> // makeSemiFutureWith(SemiFuture<T>()) -> SemiFuture<T>
template <class F> template <class F>
typename std::enable_if< typename std::enable_if<
...@@ -246,6 +242,12 @@ SemiFuture<T>::~SemiFuture() { ...@@ -246,6 +242,12 @@ SemiFuture<T>::~SemiFuture() {
detach(); detach();
} }
// This must be defined after the constructors to avoid a bug in MSVC
// https://connect.microsoft.com/VisualStudio/feedback/details/3142777/out-of-line-constructor-definition-after-implicit-reference-causes-incorrect-c2244
inline SemiFuture<Unit> makeSemiFuture() {
return makeSemiFuture(Unit{});
}
template <class T> template <class T>
T& SemiFuture<T>::value() & { T& SemiFuture<T>::value() & {
throwIfInvalid(); throwIfInvalid();
......
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