From c4d769a586d9f72ff4d209c51c44e23591965df9 Mon Sep 17 00:00:00 2001 From: Felix Glinka Date: Fri, 21 Jun 2024 15:30:12 +0200 Subject: [PATCH 1/2] Add explicit constructor to struct Profile Not adding the constructor causes a compilation error on Ubuntu 22.04 with both clang 14 and gcc 11: /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/alloc_traits.h:518:4: error: no matching function for call to 'construct_at' std::construct_at(__p, std::forward<_Args>(__args)...); ^~~~~~~~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/vector.tcc:117:21: note: in instantiation of function template specialization 'std::allocator_traits>::construct' requested here _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, ^ ../src/modules/power_profiles_daemon.cpp:106:26: note: in instantiation of function template specialization 'std::vector::emplace_back' requested here availableProfiles_.emplace_back(std::move(name), std::move(driver)); ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_construct.h:94:5: note: candidate template ignored: substitution failure [with _Tp = waybar::modules::Profile, _Args = ]: no matching constructor for initialization of 'waybar::modules::Profile' construct_at(_Tp* __location, _Args&&... __args) ^ --- include/modules/power_profiles_daemon.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/modules/power_profiles_daemon.hpp b/include/modules/power_profiles_daemon.hpp index edd9fe00..8bc250b8 100644 --- a/include/modules/power_profiles_daemon.hpp +++ b/include/modules/power_profiles_daemon.hpp @@ -10,6 +10,10 @@ namespace waybar::modules { struct Profile { std::string name; std::string driver; + + Profile(std::string n, std::string d) + : name(std::move(n)), driver(std::move(d)){ + } }; class PowerProfilesDaemon : public ALabel { From 136b207a12b8c4de9666150f31b7c9d688fc9c55 Mon Sep 17 00:00:00 2001 From: Felix Glinka Date: Fri, 21 Jun 2024 16:43:21 +0200 Subject: [PATCH 2/2] Add suggestion by clang-format --- include/modules/power_profiles_daemon.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/modules/power_profiles_daemon.hpp b/include/modules/power_profiles_daemon.hpp index 8bc250b8..a2bd3858 100644 --- a/include/modules/power_profiles_daemon.hpp +++ b/include/modules/power_profiles_daemon.hpp @@ -11,9 +11,7 @@ struct Profile { std::string name; std::string driver; - Profile(std::string n, std::string d) - : name(std::move(n)), driver(std::move(d)){ - } + Profile(std::string n, std::string d) : name(std::move(n)), driver(std::move(d)) {} }; class PowerProfilesDaemon : public ALabel {