Skip to content

Commit

Permalink
Merge pull request #1845
Browse files Browse the repository at this point in the history
Switch to clang-format 18
  • Loading branch information
Neverlord committed Apr 18, 2024
2 parents b1611be + dd6137d commit fffdce9
Show file tree
Hide file tree
Showing 18 changed files with 82 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-formatting.yml
Expand Up @@ -12,4 +12,4 @@ jobs:
- name: Run clang-format.
uses: jidicula/clang-format-action@v4.11.0
with:
clang-format-version: '17'
clang-format-version: '18'
8 changes: 2 additions & 6 deletions examples/remoting/distributed_calculator.cpp
Expand Up @@ -94,12 +94,8 @@ struct client_state {

behavior unconnected() {
return {
[this](add_atom op, int x, int y) {
tasks.emplace_back(task{op, x, y});
},
[this](sub_atom op, int x, int y) {
tasks.emplace_back(task{op, x, y});
},
[this](add_atom op, int x, int y) { tasks.emplace_back(task{op, x, y}); },
[this](sub_atom op, int x, int y) { tasks.emplace_back(task{op, x, y}); },
[this](connect_atom, const std::string& host, uint16_t port) {
connecting(host, port);
},
Expand Down
4 changes: 2 additions & 2 deletions libcaf_core/caf/abstract_actor.hpp
Expand Up @@ -238,8 +238,8 @@ class CAF_CORE_EXPORT abstract_actor {
/// identical, independently from the order of `p1` and `p2`.
template <class F>
static auto joined_exclusive_critical_section(abstract_actor* p1,
abstract_actor* p2, F fun)
-> decltype(fun()) {
abstract_actor* p2,
F fun) -> decltype(fun()) {
// Make sure to allocate locks always in the same order by starting on the
// actor with the lowest address.
CAF_ASSERT(p1 != p2 && p1 != nullptr && p2 != nullptr);
Expand Down
2 changes: 1 addition & 1 deletion libcaf_core/caf/actor_ostream.cpp
Expand Up @@ -17,7 +17,7 @@ actor_ostream::actor_ostream(local_actor* self)

actor_ostream::actor_ostream(scoped_actor& self)
: actor_ostream(
static_cast<local_actor*>(actor_cast<abstract_actor*>(self))) {
static_cast<local_actor*>(actor_cast<abstract_actor*>(self))) {
// nop
}

Expand Down
16 changes: 4 additions & 12 deletions libcaf_core/caf/blocking_mail.test.cpp
Expand Up @@ -182,9 +182,7 @@ TEST("receive response as an expected") {
return {
[](get_atom) {},
[](get_atom, int x) { return x; },
[](get_atom, int x, int y) -> result<int, int> {
return {x, y};
},
[](get_atom, int x, int y) -> result<int, int> { return {x, y}; },
};
});
SECTION("empty result") {
Expand All @@ -205,9 +203,7 @@ TEST("receive response as an expected") {
return {
[](get_atom) {},
[](get_atom, int x) { return x; },
[](get_atom, int x, int y) -> result<int, int> {
return {x, y};
},
[](get_atom, int x, int y) -> result<int, int> { return {x, y}; },
};
});
SECTION("empty result") {
Expand Down Expand Up @@ -288,9 +284,7 @@ TEST("receive response as an expected") {
return {
[](get_atom) {},
[](get_atom, int x) { return x; },
[](get_atom, int x, int y) -> result<int, int> {
return {x, y};
},
[](get_atom, int x, int y) -> result<int, int> { return {x, y}; },
};
});
SECTION("empty result") {
Expand All @@ -316,9 +310,7 @@ TEST("receive response as an expected") {
return {
[](get_atom) {},
[](get_atom, int x) { return x; },
[](get_atom, int x, int y) -> result<int, int> {
return {x, y};
},
[](get_atom, int x, int y) -> result<int, int> { return {x, y}; },
};
});
SECTION("empty result") {
Expand Down
24 changes: 12 additions & 12 deletions libcaf_core/caf/cow_vector.hpp
Expand Up @@ -173,38 +173,38 @@ class cow_vector {
// -- comparison ---------------------------------------------------------------

template <class T>
auto operator==(const cow_vector<T>& xs, const cow_vector<T>& ys)
-> decltype(xs.std() == ys.std()) {
auto operator==(const cow_vector<T>& xs,
const cow_vector<T>& ys) -> decltype(xs.std() == ys.std()) {
return xs.std() == ys.std();
}

template <class T>
auto operator==(const cow_vector<T>& xs, const std::vector<T>& ys)
-> decltype(xs.std() == ys) {
auto operator==(const cow_vector<T>& xs,
const std::vector<T>& ys) -> decltype(xs.std() == ys) {
return xs.std() == ys;
}

template <class T>
auto operator==(const std::vector<T>& xs, const cow_vector<T>& ys)
-> decltype(xs == ys.std()) {
auto operator==(const std::vector<T>& xs,
const cow_vector<T>& ys) -> decltype(xs == ys.std()) {
return xs.std() == ys;
}

template <class T>
auto operator!=(const cow_vector<T>& xs, const cow_vector<T>& ys)
-> decltype(xs.std() != ys.std()) {
auto operator!=(const cow_vector<T>& xs,
const cow_vector<T>& ys) -> decltype(xs.std() != ys.std()) {
return xs.std() != ys.std();
}

template <class T>
auto operator!=(const cow_vector<T>& xs, const std::vector<T>& ys)
-> decltype(xs.std() != ys) {
auto operator!=(const cow_vector<T>& xs,
const std::vector<T>& ys) -> decltype(xs.std() != ys) {
return xs.std() != ys;
}

template <class T>
auto operator!=(const std::vector<T>& xs, const cow_vector<T>& ys)
-> decltype(xs != ys.std()) {
auto operator!=(const std::vector<T>& xs,
const cow_vector<T>& ys) -> decltype(xs != ys.std()) {
return xs.std() != ys;
}

Expand Down
8 changes: 4 additions & 4 deletions libcaf_core/caf/detail/apply_args.hpp
Expand Up @@ -34,8 +34,8 @@ decltype(auto) apply_args(F& f, Tuple& tup) {
}

template <class F, long... Is, class Tuple>
auto apply_moved_args(F& f, detail::int_list<Is...>, Tuple& tup)
-> decltype(f(std::move(get<Is>(tup))...)) {
auto apply_moved_args(F& f, detail::int_list<Is...>,
Tuple& tup) -> decltype(f(std::move(get<Is>(tup))...)) {
return f(std::move(get<Is>(tup))...);
}

Expand All @@ -55,8 +55,8 @@ auto apply_args_auto_move(Fn& fn, FnArgs, detail::int_list<Is...>, Tuple& tup) {
}

template <class F, class Tuple, class... Ts>
auto apply_args_prefixed(F& f, detail::int_list<>, Tuple&, Ts&&... xs)
-> decltype(f(std::forward<Ts>(xs)...)) {
auto apply_args_prefixed(F& f, detail::int_list<>, Tuple&,
Ts&&... xs) -> decltype(f(std::forward<Ts>(xs)...)) {
return f(std::forward<Ts>(xs)...);
}

Expand Down
2 changes: 1 addition & 1 deletion libcaf_core/caf/detail/init_fun_factory.hpp
Expand Up @@ -132,7 +132,7 @@ class init_fun_factory {
using helper = init_fun_factory_helper<Base, F, tuple_type, rets, selfptr>;
return ptr_type{new helper{std::move(f), sizeof...(Ts) > 0
? std::make_shared<tuple_type>(
detail::spawn_fwd<Ts>(xs)...)
detail::spawn_fwd<Ts>(xs)...)
: nullptr}};
}

Expand Down
16 changes: 8 additions & 8 deletions libcaf_core/caf/detail/type_traits.hpp
Expand Up @@ -528,8 +528,8 @@ template <class T>
struct has_size {
private:
template <class List>
static auto sfinae(List* l)
-> decltype(static_cast<void>(l->size()), std::true_type());
static auto
sfinae(List* l) -> decltype(static_cast<void>(l->size()), std::true_type());

template <class U>
static auto sfinae(...) -> std::false_type;
Expand Down Expand Up @@ -653,8 +653,8 @@ template <class Inspector, class T>
class has_inspect_overload {
private:
template <class U>
static auto sfinae(Inspector& x, U& y)
-> decltype(inspect(x, y), std::true_type{});
static auto
sfinae(Inspector& x, U& y) -> decltype(inspect(x, y), std::true_type{});

static std::false_type sfinae(Inspector&, ...);

Expand All @@ -675,8 +675,8 @@ template <class Inspector, class T>
class has_builtin_inspect {
private:
template <class I, class U>
static auto sfinae(I& f, U& x)
-> decltype(f.builtin_inspect(x), std::true_type{});
static auto
sfinae(I& f, U& x) -> decltype(f.builtin_inspect(x), std::true_type{});

template <class I>
static std::false_type sfinae(I&, ...);
Expand All @@ -698,8 +698,8 @@ template <class Inspector, class T>
class accepts_opaque_value {
private:
template <class F, class U>
static auto sfinae(F* f, U* x)
-> decltype(f->opaque_value(*x), std::true_type{});
static auto
sfinae(F* f, U* x) -> decltype(f->opaque_value(*x), std::true_type{});

static std::false_type sfinae(...);

Expand Down
8 changes: 4 additions & 4 deletions libcaf_core/caf/expected.hpp
Expand Up @@ -543,8 +543,8 @@ class expected {

/// @relates expected
template <class T>
auto operator==(const expected<T>& x, const expected<T>& y)
-> decltype(*x == *y) {
auto operator==(const expected<T>& x,
const expected<T>& y) -> decltype(*x == *y) {
return x && y ? *x == *y : (!x && !y ? x.error() == y.error() : false);
}

Expand Down Expand Up @@ -588,8 +588,8 @@ operator==(Enum x, const expected<T>& y) {

/// @relates expected
template <class T>
auto operator!=(const expected<T>& x, const expected<T>& y)
-> decltype(*x == *y) {
auto operator!=(const expected<T>& x,
const expected<T>& y) -> decltype(*x == *y) {
return !(x == y);
}

Expand Down
4 changes: 1 addition & 3 deletions libcaf_core/caf/function_view.test.cpp
Expand Up @@ -47,9 +47,7 @@ using doubler = typed_actor<result<int, int>(int)>;

doubler::behavior_type simple_doubler() {
return {
[](int x) -> result<int, int> {
return {x, x};
},
[](int x) -> result<int, int> { return {x, x}; },
};
}

Expand Down
18 changes: 10 additions & 8 deletions libcaf_core/caf/log/event.hpp
Expand Up @@ -278,10 +278,11 @@ class CAF_CORE_EXPORT event_fields_builder {

/// Adds nested fields.
template <class SubFieldsInitializer>
auto
field(std::string_view key, SubFieldsInitializer&& init) -> std::enable_if_t<
std::is_same_v<decltype(init(std::declval<event_fields_builder&>())), void>,
event_fields_builder&> {
auto field(std::string_view key, SubFieldsInitializer&& init)
-> std::enable_if_t<
std::is_same_v<decltype(init(std::declval<event_fields_builder&>())),
void>,
event_fields_builder&> {
auto& field = fields_.emplace_back(std::string_view{}, std::nullopt);
field.key = deep_copy(key);
event_fields_builder nested_builder{resource()};
Expand Down Expand Up @@ -380,10 +381,11 @@ class CAF_CORE_EXPORT event_sender {

/// Adds nested fields.
template <class SubFieldsInitializer>
auto
field(std::string_view key, SubFieldsInitializer&& init) -> std::enable_if_t<
std::is_same_v<decltype(init(std::declval<event_fields_builder&>())), void>,
event_sender&&> {
auto field(std::string_view key, SubFieldsInitializer&& init)
-> std::enable_if_t<
std::is_same_v<decltype(init(std::declval<event_fields_builder&>())),
void>,
event_sender&&> {
if (logger_)
fields_.field(key, std::forward<SubFieldsInitializer>(init));
return std::move(*this);
Expand Down
4 changes: 2 additions & 2 deletions libcaf_core/caf/scheduled_actor.cpp
Expand Up @@ -872,8 +872,8 @@ bool scheduled_actor::activate(scheduler* sched) {
return true;
}

auto scheduled_actor::activate(scheduler* sched, mailbox_element& x)
-> activation_result {
auto scheduled_actor::activate(scheduler* sched,
mailbox_element& x) -> activation_result {
auto lg = log::core::trace("x = {}", x);
if (!activate(sched))
return activation_result::terminated;
Expand Down
12 changes: 7 additions & 5 deletions libcaf_core/caf/scheduled_actor.hpp
Expand Up @@ -510,9 +510,10 @@ class CAF_CORE_EXPORT scheduled_actor : public abstract_scheduled_actor,
/// Utility function that swaps `f` into a temporary before calling it
/// and restoring `f` only if it has not been replaced by the user.
template <class F, class... Ts>
auto call_handler(F& f, Ts&&... xs) -> std::enable_if_t<
!std::is_same_v<decltype(f(std::forward<Ts>(xs)...)), void>,
decltype(f(std::forward<Ts>(xs)...))> {
auto call_handler(F& f, Ts&&... xs)
-> std::enable_if_t<
!std::is_same_v<decltype(f(std::forward<Ts>(xs)...)), void>,
decltype(f(std::forward<Ts>(xs)...))> {
using std::swap;
F g;
swap(f, g);
Expand All @@ -523,8 +524,9 @@ class CAF_CORE_EXPORT scheduled_actor : public abstract_scheduled_actor,
}

template <class F, class... Ts>
auto call_handler(F& f, Ts&&... xs) -> std::enable_if_t<
std::is_same_v<decltype(f(std::forward<Ts>(xs)...)), void>> {
auto call_handler(F& f, Ts&&... xs)
-> std::enable_if_t<
std::is_same_v<decltype(f(std::forward<Ts>(xs)...)), void>> {
using std::swap;
F g;
swap(f, g);
Expand Down
30 changes: 16 additions & 14 deletions libcaf_core/caf/serialization.test.cpp
Expand Up @@ -521,25 +521,27 @@ struct fixture : caf::test::fixture::deterministic {
if (type == "map") {
std::map<std::string, int32_t> imap;
caf::split(parsed_value, value, ",");
std::transform(
parsed_value.cbegin(), parsed_value.cend(),
std::inserter(imap, imap.begin()), [](const std::string& s) {
str_list parsed_pair;
caf::split(parsed_pair, s, ":");
return std::pair{parsed_pair[0], std::stoi(parsed_pair[1])};
});
std::transform(parsed_value.cbegin(), parsed_value.cend(),
std::inserter(imap, imap.begin()),
[](const std::string& s) {
str_list parsed_pair;
caf::split(parsed_pair, s, ":");
return std::pair{parsed_pair[0],
std::stoi(parsed_pair[1])};
});
return imap;
}
if (type == "umap") {
std::unordered_map<std::string, int32_t> iumap;
caf::split(parsed_value, value, ",");
std::transform(
parsed_value.cbegin(), parsed_value.cend(),
std::inserter(iumap, iumap.begin()), [](const std::string& s) {
str_list parsed_pair;
caf::split(parsed_pair, s, ":");
return std::pair{parsed_pair[0], std::stoi(parsed_pair[1])};
});
std::transform(parsed_value.cbegin(), parsed_value.cend(),
std::inserter(iumap, iumap.begin()),
[](const std::string& s) {
str_list parsed_pair;
caf::split(parsed_pair, s, ":");
return std::pair{parsed_pair[0],
std::stoi(parsed_pair[1])};
});
return iumap;
}
if (type == "set") {
Expand Down
4 changes: 2 additions & 2 deletions libcaf_core/caf/settings.hpp
Expand Up @@ -135,8 +135,8 @@ template <class T>
struct has_init {
private:
template <class U>
static auto sfinae(U* x, settings* y = nullptr)
-> decltype(x->init(*y), std::true_type());
static auto sfinae(U* x, settings* y = nullptr) -> decltype(x->init(*y),
std::true_type());

template <class U>
static auto sfinae(...) -> std::false_type;
Expand Down
8 changes: 4 additions & 4 deletions libcaf_test/caf/test/unit_test.hpp
Expand Up @@ -105,10 +105,10 @@ struct inequality_operator {
static constexpr bool default_value = true;

template <class T, class U,
std::enable_if_t<
(std::is_floating_point_v<T>
|| std::is_floating_point_v<U>) &&detail::is_comparable_v<T, U>,
int>
std::enable_if_t<(std::is_floating_point_v<T>
|| std::is_floating_point_v<U>)
&& detail::is_comparable_v<T, U>,
int>
= 0>
bool operator()(const T& x, const U& y) const {
equality_operator f;
Expand Down
4 changes: 1 addition & 3 deletions robot/stream/driver.cpp
Expand Up @@ -60,9 +60,7 @@ behavior producer(event_based_actor* self) {
return self->make_observable()
.iota(1)
.take(9)
.map([](int x) {
return point{x, x * x};
})
.map([](int x) { return point{x, x * x}; })
.to_stream("points", max_batch_delay, max_batch_size);
},
};
Expand Down

0 comments on commit fffdce9

Please sign in to comment.