Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c022eadc authored by Pirama Arumuga Nainar's avatar Pirama Arumuga Nainar
Browse files

FTL: Provide definition of BaseFuture where third template parameter is ftl::Future

Bug: 405867217

After https://github.com/llvm/llvm-project/pull/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
parent a83d862d
Loading
Loading
Loading
Loading
+5 −9
Original line number Diff line number Diff line
@@ -48,12 +48,8 @@ using future_result_t = typename future_result<T>::type;

struct ValueTag {};

template <typename, typename T, template <typename> class>
class BaseFuture;

template <typename Self, typename T>
class BaseFuture<Self, T, std::future> {
  using Impl = std::future<T>;
template <typename Self, typename T, template <typename> class FutureImpl = std::future>
class BaseFuture {

 public:
  Future<T, std::shared_future> share() {
@@ -61,7 +57,7 @@ class BaseFuture<Self, T, std::future> {
      return {ValueTag{}, std::move(*value)};
    }

    return std::get<Impl>(self()).share();
    return std::get<FutureImpl<T>>(self()).share();
  }

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

    return std::get<Impl>(self()).get();
    return std::get<FutureImpl<T>>(self()).get();
  }

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

    return std::get<Impl>(self()).wait_for(timeout_duration);
    return std::get<FutureImpl<T>>(self()).wait_for(timeout_duration);
  }

 private: