Skip to content

Commit c022ead

Browse files
FTL: Provide definition of BaseFuture where third template parameter is ftl::Future
Bug: 405867217 After llvm/llvm-project#100692, clang is stricter about template deductions. This causes the following error in future_test.cpp: ...s/native/include/ftl/future.h:34:29: error: implicit instantiation of undefined template 'android::ftl::details::BaseFuture<android::ftl::Future<int, android::ftl::Future>, int, android::ftl::Future>' 34 | class Future final : public details::BaseFuture<Future<T, FutureImpl>, T, FutureImpl> { | ^ frameworks/native/libs/ftl/future_test.cpp:47:31: note: in instantiation of template class 'android::ftl::Future<int, android::ftl::Future>' requested here 47 | ftl::Future<char> chain = ftl::Future(std::move(future)) | ^ frameworks/native/include/ftl/details/future.h:52:7: note: template is declared here 52 | class BaseFuture; | ^ This is because ftl/details/future.h only provides an instantiation where the third template parameter is either a std::future or a std::shared_future. This change extends the instantiation to support any FutureImpl. Test: Build future_test.cpp with new clang and old clang, in addition to presubmit. Flag: EXEMPT fix error during compiler update Change-Id: I1795f1f1237f5209fd8138a20c4de2a921c7395b
1 parent a83d862 commit c022ead

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

include/ftl/details/future.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,16 @@ using future_result_t = typename future_result<T>::type;
4848

4949
struct ValueTag {};
5050

51-
template <typename, typename T, template <typename> class>
52-
class BaseFuture;
53-
54-
template <typename Self, typename T>
55-
class BaseFuture<Self, T, std::future> {
56-
using Impl = std::future<T>;
51+
template <typename Self, typename T, template <typename> class FutureImpl = std::future>
52+
class BaseFuture {
5753

5854
public:
5955
Future<T, std::shared_future> share() {
6056
if (T* value = std::get_if<T>(&self())) {
6157
return {ValueTag{}, std::move(*value)};
6258
}
6359

64-
return std::get<Impl>(self()).share();
60+
return std::get<FutureImpl<T>>(self()).share();
6561
}
6662

6763
protected:
@@ -70,7 +66,7 @@ class BaseFuture<Self, T, std::future> {
7066
return std::move(*value);
7167
}
7268

73-
return std::get<Impl>(self()).get();
69+
return std::get<FutureImpl<T>>(self()).get();
7470
}
7571

7672
template <class Rep, class Period>
@@ -79,7 +75,7 @@ class BaseFuture<Self, T, std::future> {
7975
return std::future_status::ready;
8076
}
8177

82-
return std::get<Impl>(self()).wait_for(timeout_duration);
78+
return std::get<FutureImpl<T>>(self()).wait_for(timeout_duration);
8379
}
8480

8581
private:

0 commit comments

Comments
 (0)