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

Commit e21dbed9 authored by Dominik Laskowski's avatar Dominik Laskowski
Browse files

FTL: Configure clang-format

Bug: 160012986
Test: ftl_test
Change-Id: Iab01c967b9318afecb21107a6c25bebc4178edcd
parent 5444fc8c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
../../../../build/soong/scripts/system-clang-format-2
 No newline at end of file
+30 −32
Original line number Diff line number Diff line
@@ -56,8 +56,7 @@ struct InitializerList<T, std::index_sequence<Sizes...>, Types...> {
  template <typename... Args>
  [[nodiscard]] constexpr auto operator()(Args&&... args) && -> InitializerList<
      T, std::index_sequence<Sizes..., sizeof...(Args)>, Types..., Args&&...> {
        return {std::tuple_cat(std::move(tuple),
                               std::forward_as_tuple(std::forward<Args>(args)...))};
    return {std::tuple_cat(std::move(tuple), std::forward_as_tuple(std::forward<Args>(args)...))};
  }

  // The temporary InitializerList returned by operator() is bound to an rvalue reference in
@@ -79,11 +78,10 @@ struct InitializerList<KeyValue<K, V>, std::index_sequence<Sizes...>, Types...>
  [[nodiscard]] constexpr auto operator()(K&& k, Args&&... args) && -> InitializerList<
      KeyValue<K, V>, std::index_sequence<Sizes..., 3>, Types..., std::piecewise_construct_t,
      std::tuple<K&&>, std::tuple<Args&&...>> {
        return {std::tuple_cat(std::move(tuple),
                               std::forward_as_tuple(std::piecewise_construct,
                                                     std::forward_as_tuple(std::forward<K>(k)),
                                                     std::forward_as_tuple(
                                                             std::forward<Args>(args)...)))};
    return {std::tuple_cat(
        std::move(tuple),
        std::forward_as_tuple(std::piecewise_construct, std::forward_as_tuple(std::forward<K>(k)),
                              std::forward_as_tuple(std::forward<Args>(args)...)))};
  }

  std::tuple<Types...> tuple;
+136 −138
Original line number Diff line number Diff line
@@ -130,8 +130,7 @@ public:
  //   ref.get() = 'D';
  //   assert(d == 'D');
  //
    auto find(const key_type& key) const
            -> std::optional<std::reference_wrapper<const mapped_type>> {
  auto find(const key_type& key) const -> std::optional<std::reference_wrapper<const mapped_type>> {
    return find(key, [](const mapped_type& v) { return std::cref(v); });
  }

@@ -167,9 +166,8 @@ public:

  template <typename F>
  auto find(const key_type& key, F f) {
        return std::as_const(*this).find(key, [&f](const mapped_type& v) {
            return f(const_cast<mapped_type&>(v));
        });
    return std::as_const(*this).find(
        key, [&f](const mapped_type& v) { return f(const_cast<mapped_type&>(v)); });
  }

 private:
+251 −255
Original line number Diff line number Diff line
@@ -64,9 +64,7 @@ struct is_small_vector;
//   assert(vector == (ftl::SmallVector{'h', 'i', '\0'}));
//   assert(!vector.dynamic());
//
//     ftl::SmallVector strings = ftl::init::list<std::string>("abc")
//                                                            ("123456", 3u)
//                                                            (3u, '?');
//   ftl::SmallVector strings = ftl::init::list<std::string>("abc")("123456", 3u)(3u, '?');
//   assert(strings.size() == 3u);
//   assert(!strings.dynamic());
//
@@ -105,8 +103,7 @@ public:
  template <typename Arg, typename... Args,
            typename = std::enable_if_t<!is_small_vector<remove_cvref_t<Arg>>{}>>
  SmallVector(Arg&& arg, Args&&... args)
          : vector_(std::in_place_type<Static>, std::forward<Arg>(arg),
                    std::forward<Args>(args)...) {}
      : vector_(std::in_place_type<Static>, std::forward<Arg>(arg), std::forward<Args>(args)...) {}

  // Copies at most N elements from a smaller convertible vector.
  template <typename U, std::size_t M, typename = std::enable_if_t<M <= N>>
@@ -207,8 +204,7 @@ public:
  }

  void push_back(value_type&& v) {
        constexpr auto kInsertStatic =
                static_cast<bool (Static::*)(value_type&&)>(&Static::push_back);
    constexpr auto kInsertStatic = static_cast<bool (Static::*)(value_type &&)>(&Static::push_back);
    constexpr auto kInsertDynamic =
        static_cast<bool (Dynamic::*)(value_type &&)>(&Dynamic::push_back);
    insert<kInsertStatic, kInsertDynamic>(std::move(v));
+310 −312
Original line number Diff line number Diff line
@@ -28,7 +28,8 @@

namespace android::ftl {

constexpr struct IteratorRangeTag {} kIteratorRange;
constexpr struct IteratorRangeTag {
} kIteratorRange;

// Fixed-capacity, statically allocated counterpart of std::vector. Like std::array, StaticVector
// allocates contiguous storage for N elements of type T at compile time, but stores at most (rather
@@ -65,9 +66,7 @@ constexpr struct IteratorRangeTag {} kIteratorRange;
//   vector = ftl::StaticVector(array);
//   assert(vector == (ftl::StaticVector{'h', 'i', '\0'}));
//
//     ftl::StaticVector strings = ftl::init::list<std::string>("abc")
//                                                             ("123456", 3u)
//                                                             (3u, '?');
//   ftl::StaticVector strings = ftl::init::list<std::string>("abc")("123456", 3u)(3u, '?');
//   assert(strings.size() == 3u);
//   assert(strings[0] == "abc");
//   assert(strings[1] == "123");
@@ -89,8 +88,8 @@ class StaticVector final : ArrayTraits<T>,
  // latter unless they are input iterators and cannot be used to construct elements. If
  // the former is intended, the caller can pass an IteratorRangeTag to disambiguate.
  template <typename I, typename Traits = std::iterator_traits<I>>
    using is_input_iterator = std::conjunction<
            std::is_base_of<std::input_iterator_tag, typename Traits::iterator_category>,
  using is_input_iterator =
      std::conjunction<std::is_base_of<std::input_iterator_tag, typename Traits::iterator_category>,
                       std::negation<std::is_constructible<T, I>>>;

 public:
@@ -323,8 +322,7 @@ private:
  StaticVector(std::index_sequence<I, ArgIndex, ArgCount>, std::index_sequence<Indices...>,
               std::index_sequence<Size, Sizes...>, std::tuple<Args...>& tuple)
      : StaticVector(std::index_sequence<I + 1, ArgIndex + ArgCount, Size>{},
                         std::make_index_sequence<Size>{}, std::index_sequence<Sizes...>{},
                         tuple) {
                     std::make_index_sequence<Size>{}, std::index_sequence<Sizes...>{}, tuple) {
    construct_at(begin() + I, std::move(std::get<ArgIndex + Indices>(tuple))...);
  }

Loading