diff options
| author | Patrick Venture <venture@google.com> | 2018-08-31 12:45:01 -0700 |
|---|---|---|
| committer | Patrick Venture <venture@google.com> | 2018-08-31 12:45:01 -0700 |
| commit | 2b238afb8c46824d3f0a6b3a615df2c57a16f7ed (patch) | |
| tree | d9eba5c000340f4a6454efbc895b1593800e3e0d | |
| parent | 95269dbc8c38fb41ac50639eafa8d8c3e57ec748 (diff) | |
| download | sdbusplus-2b238afb8c46824d3f0a6b3a615df2c57a16f7ed.tar.gz sdbusplus-2b238afb8c46824d3f0a6b3a615df2c57a16f7ed.zip | |
clang-format: always break template declarations
To better match the defined openbmc style.
Change-Id: I68cda43857768bae4c904c367942cb1f0efa3e0c
Signed-off-by: Patrick Venture <venture@google.com>
| -rw-r--r-- | .clang-format | 2 | ||||
| -rw-r--r-- | mapbox/recursive_wrapper.hpp | 3 | ||||
| -rw-r--r-- | mapbox/variant.hpp | 69 | ||||
| -rw-r--r-- | sdbusplus/asio/detail/async_send_handler.hpp | 3 | ||||
| -rw-r--r-- | sdbusplus/message.hpp | 6 | ||||
| -rw-r--r-- | sdbusplus/message/append.hpp | 51 | ||||
| -rw-r--r-- | sdbusplus/message/native_types.hpp | 3 | ||||
| -rw-r--r-- | sdbusplus/message/read.hpp | 42 | ||||
| -rw-r--r-- | sdbusplus/message/types.hpp | 93 | ||||
| -rw-r--r-- | sdbusplus/server/bindings.hpp | 3 | ||||
| -rw-r--r-- | sdbusplus/server/object.hpp | 18 | ||||
| -rw-r--r-- | sdbusplus/server/transaction.hpp | 12 | ||||
| -rw-r--r-- | sdbusplus/utility/container_traits.hpp | 18 | ||||
| -rw-r--r-- | sdbusplus/utility/read_into_tuple.hpp | 3 | ||||
| -rw-r--r-- | sdbusplus/utility/type_traits.hpp | 12 | ||||
| -rw-r--r-- | test/message/append.cpp | 3 | ||||
| -rw-r--r-- | test/message/read.cpp | 3 | ||||
| -rw-r--r-- | test/message/types.cpp | 3 |
18 files changed, 231 insertions, 116 deletions
diff --git a/.clang-format b/.clang-format index 00d9a54..42a2307 100644 --- a/.clang-format +++ b/.clang-format @@ -17,7 +17,7 @@ AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: false +AlwaysBreakTemplateDeclarations: true BinPackArguments: true BinPackParameters: true BraceWrapping: diff --git a/mapbox/recursive_wrapper.hpp b/mapbox/recursive_wrapper.hpp index af569ef..c90a88c 100644 --- a/mapbox/recursive_wrapper.hpp +++ b/mapbox/recursive_wrapper.hpp @@ -20,7 +20,8 @@ namespace mapbox namespace util { -template <typename T> class recursive_wrapper +template <typename T> +class recursive_wrapper { T* p_; diff --git a/mapbox/variant.hpp b/mapbox/variant.hpp index 2019fc5..14fe75c 100644 --- a/mapbox/variant.hpp +++ b/mapbox/variant.hpp @@ -78,7 +78,8 @@ class bad_variant_access : public std::runtime_error }; // class bad_variant_access -template <typename R = void> struct MAPBOX_VARIANT_DEPRECATED static_visitor +template <typename R = void> +struct MAPBOX_VARIANT_DEPRECATED static_visitor { using result_type = R; @@ -96,7 +97,8 @@ namespace detail static constexpr std::size_t invalid_value = std::size_t(-1); -template <typename T, typename... Types> struct direct_type; +template <typename T, typename... Types> +struct direct_type; template <typename T, typename First, typename... Types> struct direct_type<T, First, Types...> @@ -106,7 +108,8 @@ struct direct_type<T, First, Types...> : direct_type<T, Types...>::index; }; -template <typename T> struct direct_type<T> +template <typename T> +struct direct_type<T> { static constexpr std::size_t index = invalid_value; }; @@ -117,11 +120,13 @@ using std::disjunction; #else -template <typename...> struct disjunction : std::false_type +template <typename...> +struct disjunction : std::false_type { }; -template <typename B1> struct disjunction<B1> : B1 +template <typename B1> +struct disjunction<B1> : B1 { }; @@ -138,7 +143,8 @@ struct disjunction<B1, Bs...> #endif -template <typename T, typename... Types> struct convertible_type; +template <typename T, typename... Types> +struct convertible_type; template <typename T, typename First, typename... Types> struct convertible_type<T, First, Types...> @@ -151,12 +157,14 @@ struct convertible_type<T, First, Types...> : convertible_type<T, Types...>::index; }; -template <typename T> struct convertible_type<T> +template <typename T> +struct convertible_type<T> { static constexpr std::size_t index = invalid_value; }; -template <typename T, typename... Types> struct value_traits +template <typename T, typename... Types> +struct value_traits { using value_type = typename std::remove_const< typename std::remove_reference<T>::type>::type; @@ -173,7 +181,8 @@ template <typename T, typename... Types> struct value_traits typename std::tuple_element<tindex, std::tuple<void, Types...>>::type; }; -template <typename T, typename R = void> struct enable_if_type +template <typename T, typename R = void> +struct enable_if_type { using type = R; }; @@ -204,9 +213,11 @@ struct result_of_binary_visit< using type = typename F::result_type; }; -template <std::size_t arg1, std::size_t... others> struct static_max; +template <std::size_t arg1, std::size_t... others> +struct static_max; -template <std::size_t arg> struct static_max<arg> +template <std::size_t arg> +struct static_max<arg> { static const std::size_t value = arg; }; @@ -219,9 +230,11 @@ struct static_max<arg1, arg2, others...> : static_max<arg2, others...>::value; }; -template <typename... Types> struct variant_helper; +template <typename... Types> +struct variant_helper; -template <typename T, typename... Types> struct variant_helper<T, Types...> +template <typename T, typename... Types> +struct variant_helper<T, Types...> { VARIANT_INLINE static void destroy(const std::size_t type_index, void* data) { @@ -264,7 +277,8 @@ template <typename T, typename... Types> struct variant_helper<T, Types...> } }; -template <> struct variant_helper<> +template <> +struct variant_helper<> { VARIANT_INLINE static void destroy(const std::size_t, void*) { @@ -277,7 +291,8 @@ template <> struct variant_helper<> } }; -template <typename T> struct unwrapper +template <typename T> +struct unwrapper { static T const& apply_const(T const& obj) { @@ -289,7 +304,8 @@ template <typename T> struct unwrapper } }; -template <typename T> struct unwrapper<recursive_wrapper<T>> +template <typename T> +struct unwrapper<recursive_wrapper<T>> { static auto apply_const(recursive_wrapper<T> const& obj) -> typename recursive_wrapper<T>::type const& @@ -303,7 +319,8 @@ template <typename T> struct unwrapper<recursive_wrapper<T>> } }; -template <typename T> struct unwrapper<std::reference_wrapper<T>> +template <typename T> +struct unwrapper<std::reference_wrapper<T>> { static auto apply_const(std::reference_wrapper<T> const& obj) -> typename std::reference_wrapper<T>::type const& @@ -549,7 +566,8 @@ struct binary_dispatcher<F, V, R, T> // comparator functors struct equal_comp { - template <typename T> bool operator()(T const& lhs, T const& rhs) const + template <typename T> + bool operator()(T const& lhs, T const& rhs) const { return lhs == rhs; } @@ -557,13 +575,15 @@ struct equal_comp struct less_comp { - template <typename T> bool operator()(T const& lhs, T const& rhs) const + template <typename T> + bool operator()(T const& lhs, T const& rhs) const { return lhs < rhs; } }; -template <typename Variant, typename Comp> class comparer +template <typename Variant, typename Comp> +class comparer { public: explicit comparer(Variant const& lhs) noexcept : lhs_(lhs) @@ -571,7 +591,8 @@ template <typename Variant, typename Comp> class comparer } comparer& operator=(comparer const&) = delete; // visitor - template <typename T> bool operator()(T const& rhs_content) const + template <typename T> + bool operator()(T const& rhs_content) const { T const& lhs_content = lhs_.template get_unchecked<T>(); return Comp()(lhs_content, rhs_content); @@ -587,7 +608,8 @@ struct no_init { }; -template <typename... Types> class variant +template <typename... Types> +class variant { static_assert(sizeof...(Types) > 0, "Template parameter type list of variant can not be empty"); @@ -1067,7 +1089,8 @@ auto get(T& var) -> decltype(var.template get<ResultType>()) } #endif -template <typename ResultType, typename T> ResultType& get_unchecked(T& var) +template <typename ResultType, typename T> +ResultType& get_unchecked(T& var) { return var.template get_unchecked<ResultType>(); } diff --git a/sdbusplus/asio/detail/async_send_handler.hpp b/sdbusplus/asio/detail/async_send_handler.hpp index 1c56eb2..ce4e394 100644 --- a/sdbusplus/asio/detail/async_send_handler.hpp +++ b/sdbusplus/asio/detail/async_send_handler.hpp @@ -27,7 +27,8 @@ namespace asio { namespace detail { -template <typename Handler> struct async_send_handler +template <typename Handler> +struct async_send_handler { Handler handler_; async_send_handler(Handler&& handler) : handler_(std::move(handler)) diff --git a/sdbusplus/message.hpp b/sdbusplus/message.hpp index dc2fe5b..ac468dc 100644 --- a/sdbusplus/message.hpp +++ b/sdbusplus/message.hpp @@ -108,7 +108,8 @@ class message * @tparam ...Args - Type of items to append to message. * @param[in] args - Items to append to message. */ - template <typename... Args> void append(Args&&... args) + template <typename... Args> + void append(Args&&... args) { sdbusplus::message::append(_intf, _msg.get(), std::forward<Args>(args)...); @@ -119,7 +120,8 @@ class message * @tparam ...Args - Type of items to read from message. * @param[out] args - Items to read from message. */ - template <typename... Args> void read(Args&&... args) + template <typename... Args> + void read(Args&&... args) { sdbusplus::message::read(_intf, _msg.get(), std::forward<Args>(args)...); diff --git a/sdbusplus/message/append.hpp b/sdbusplus/message/append.hpp index 0451bdd..efea26d 100644 --- a/sdbusplus/message/append.hpp +++ b/sdbusplus/message/append.hpp @@ -53,19 +53,23 @@ struct can_append_multiple : std::true_type { }; // std::string needs a c_str() call. -template <> struct can_append_multiple<std::string> : std::false_type +template <> +struct can_append_multiple<std::string> : std::false_type { }; // object_path needs a c_str() call. -template <> struct can_append_multiple<object_path> : std::false_type +template <> +struct can_append_multiple<object_path> : std::false_type { }; // signature needs a c_str() call. -template <> struct can_append_multiple<signature> : std::false_type +template <> +struct can_append_multiple<signature> : std::false_type { }; // bool needs to be resized to int, per sdbus documentation. -template <> struct can_append_multiple<bool> : std::false_type +template <> +struct can_append_multiple<bool> : std::false_type { }; // std::vector/map/unordered_map/set need loops @@ -99,10 +103,12 @@ struct can_append_multiple<variant<Args...>> : std::false_type * * @tparam S - Type of element to append. */ -template <typename S, typename Enable = void> struct append_single +template <typename S, typename Enable = void> +struct append_single { // Downcast - template <typename T> using Td = types::details::type_id_downcast_t<T>; + template <typename T> + using Td = types::details::type_id_downcast_t<T>; // sd_bus_message_append_basic expects a T* (cast to void*) for most types, // so t& is appropriate. In the case of char*, it expects the void* is @@ -110,16 +116,19 @@ template <typename S, typename Enable = void> struct append_single // // Use these helper templates 'address_of(t)' in place of '&t' to // handle both cases. - template <typename T> static auto address_of_helper(T&& t, std::false_type) + template <typename T> + static auto address_of_helper(T&& t, std::false_type) { return &t; } - template <typename T> static auto address_of_helper(T&& t, std::true_type) + template <typename T> + static auto address_of_helper(T&& t, std::true_type) { return t; } - template <typename T> static auto address_of(T&& t) + template <typename T> + static auto address_of(T&& t) { return address_of_helper(std::forward<T>(t), std::is_pointer<std::remove_reference_t<T>>()); @@ -158,7 +167,8 @@ template <typename T> using append_single_t = append_single<types::details::type_id_downcast_t<T>>; /** @brief Specialization of append_single for std::strings. */ -template <> struct append_single<std::string> +template <> +struct append_single<std::string> { template <typename T> static void op(sdbusplus::SdBusInterface* intf, sd_bus_message* m, T&& s) @@ -169,7 +179,8 @@ template <> struct append_single<std::string> }; /** @brief Specialization of append_single for details::string_wrapper. */ -template <typename T> struct append_single<details::string_wrapper<T>> +template <typename T> +struct append_single<details::string_wrapper<T>> { template <typename S> static void op(sdbusplus::SdBusInterface* intf, sd_bus_message* m, S&& s) @@ -180,7 +191,8 @@ template <typename T> struct append_single<details::string_wrapper<T>> }; /** @brief Specialization of append_single for bool. */ -template <> struct append_single<bool> +template <> +struct append_single<bool> { template <typename T> static void op(sdbusplus::SdBusInterface* intf, sd_bus_message* m, T&& b) @@ -212,7 +224,8 @@ struct append_single<T, std::enable_if_t<utility::has_const_iterator<T>::value>> }; /** @brief Specialization of append_single for std::pairs. */ -template <typename T1, typename T2> struct append_single<std::pair<T1, T2>> +template <typename T1, typename T2> +struct append_single<std::pair<T1, T2>> { template <typename S> static void op(sdbusplus::SdBusInterface* intf, sd_bus_message* m, S&& s) @@ -228,7 +241,8 @@ template <typename T1, typename T2> struct append_single<std::pair<T1, T2>> }; /** @brief Specialization of append_single for std::tuples. */ -template <typename... Args> struct append_single<std::tuple<Args...>> +template <typename... Args> +struct append_single<std::tuple<Args...>> { template <typename S, std::size_t... I> static void _op(sdbusplus::SdBusInterface* intf, sd_bus_message* m, S&& s, @@ -253,7 +267,8 @@ template <typename... Args> struct append_single<std::tuple<Args...>> }; /** @brief Specialization of append_single for std::variant. */ -template <typename... Args> struct append_single<variant<Args...>> +template <typename... Args> +struct append_single<variant<Args...>> { template <typename S, typename = std::enable_if_t<0 < sizeof...(Args)>> static void op(sdbusplus::SdBusInterface* intf, sd_bus_message* m, S&& s) @@ -279,7 +294,8 @@ static void tuple_item_append(sdbusplus::SdBusInterface* intf, sdbusplus::message::append(intf, m, t); } -template <int Index> struct AppendHelper +template <int Index> +struct AppendHelper { template <typename... Fields> static void op(sdbusplus::SdBusInterface* intf, sd_bus_message* m, @@ -293,7 +309,8 @@ template <int Index> struct AppendHelper } }; -template <> struct AppendHelper<1> +template <> +struct AppendHelper<1> { template <typename... Fields> static void op(sdbusplus::SdBusInterface* intf, sd_bus_message* m, diff --git a/sdbusplus/message/native_types.hpp b/sdbusplus/message/native_types.hpp index 11a4b23..b67c7e1 100644 --- a/sdbusplus/message/native_types.hpp +++ b/sdbusplus/message/native_types.hpp @@ -13,7 +13,8 @@ namespace details /** Simple wrapper class for std::string to allow conversion to and from an * alternative typename. */ -template <typename T> struct string_wrapper +template <typename T> +struct string_wrapper { std::string str; diff --git a/sdbusplus/message/read.hpp b/sdbusplus/message/read.hpp index b3fb73b..2035d30 100644 --- a/sdbusplus/message/read.hpp +++ b/sdbusplus/message/read.hpp @@ -52,19 +52,23 @@ struct can_read_multiple : std::true_type { }; // std::string needs a char* conversion. -template <> struct can_read_multiple<std::string> : std::false_type +template <> +struct can_read_multiple<std::string> : std::false_type { }; // object_path needs a char* conversion. -template <> struct can_read_multiple<object_path> : std::false_type +template <> +struct can_read_multiple<object_path> : std::false_type { }; // signature needs a char* conversion. -template <> struct can_read_multiple<signature> : std::false_type +template <> +struct can_read_multiple<signature> : std::false_type { }; // bool needs to be resized to int, per sdbus documentation. -template <> struct can_read_multiple<bool> : std::false_type +template <> +struct can_read_multiple<bool> : std::false_type { }; @@ -103,10 +107,12 @@ struct can_read_multiple<variant<Args...>> : std::false_type * * @tparam S - Type of element to read. */ -template <typename S, typename Enable = void> struct read_single +template <typename S, typename Enable = void> +struct read_single { // Downcast - template <typename T> using Td = types::details::type_id_downcast_t<T>; + template <typename T> + using Td = types::details::type_id_downcast_t<T>; /** @brief Do the operation to read element. * @@ -145,7 +151,8 @@ template <typename T> using read_single_t = read_single<types::details::type_id_downcast_t<T>>; /** @brief Specialization of read_single for std::strings. */ -template <> struct read_single<std::string> +template <> +struct read_single<std::string> { template <typename T> static void op(sdbusplus::SdBusInterface* intf, sd_bus_message* m, T&& s) @@ -162,7 +169,8 @@ template <> struct read_single<std::string> }; /** @brief Specialization of read_single for details::string_wrapper. */ -template <typename T> struct read_single<details::string_wrapper<T>> +template <typename T> +struct read_single<details::string_wrapper<T>> { template <typename S> static void op(sdbusplus::SdBusInterface* intf, sd_bus_message* m, S&& s) @@ -180,7 +188,8 @@ template <typename T> struct read_single<details::string_wrapper<T>> }; /** @brief Specialization of read_single for bools. */ -template <> struct read_single<bool> +template <> +struct read_single<bool> { template <typename T> static void op(sdbusplus::SdBusInterface* intf, sd_bus_message* m, T&& b) @@ -272,7 +281,8 @@ struct read_single<T, std::enable_if_t<utility::has_emplace_method<T>::value>> }; /** @brief Specialization of read_single for std::pairs. */ -template <typename T1, typename T2> struct read_single<std::pair<T1, T2>> +template <typename T1, typename T2> +struct read_single<std::pair<T1, T2>> { template <typename S> static void op(sdbusplus::SdBusInterface* intf, sd_bus_message* m, S&& s) @@ -300,7 +310,8 @@ template <typename T1, typename T2> struct read_single<std::pair<T1, T2>> }; /** @brief Specialization of read_single for std::tuples. */ -template <typename... Args> struct read_single<std::tuple<Args...>> +template <typename... Args> +struct read_single<std::tuple<Args...>> { template <typename S, std::size_t... I> static void _op(sdbusplus::SdBusInterface* intf, sd_bus_message* m, S&& s, @@ -337,7 +348,8 @@ template <typename... Args> struct read_single<std::tuple<Args...>> }; /** @brief Specialization of read_single for std::variant. */ -template <typename... Args> struct read_single<variant<Args...>> +template <typename... Args> +struct read_single<variant<Args...>> { template <typename S, typename S1, typename... Args1> static void read(sdbusplus::SdBusInterface* intf, sd_bus_message* m, S&& s) @@ -404,7 +416,8 @@ static void tuple_item_read(sdbusplus::SdBusInterface* intf, sd_bus_message* m, sdbusplus::message::read(intf, m, t); } -template <int Index> struct ReadHelper +template <int Index> +struct ReadHelper { template <typename... Fields> static void op(sdbusplus::SdBusInterface* intf, sd_bus_message* m, @@ -418,7 +431,8 @@ template <int Index> struct ReadHelper } }; -template <> struct ReadHelper<1> +template <> +struct ReadHelper<1> { template <typename... Fields> static void op(sdbusplus::SdBusInterface* intf, sd_bus_message* m, diff --git a/sdbusplus/message/types.hpp b/sdbusplus/message/types.hpp index 6156c0e..4dd5e3d 100644 --- a/sdbusplus/message/types.hpp +++ b/sdbusplus/message/types.hpp @@ -19,7 +19,8 @@ namespace message namespace variant_ns = mapbox::util; -template <typename... Args> using variant = variant_ns::variant<Args...>; +template <typename... Args> +using variant = variant_ns::variant<Args...>; namespace types { @@ -38,13 +39,15 @@ namespace types * options at compile-time the use of type-deduced dbus strings is equal to * the cost of hard-coded type string constants. */ -template <typename... Args> constexpr auto type_id(); +template <typename... Args> +constexpr auto type_id(); /** @fn type_id_nonull() * @brief A non-null-terminated version of type_id. * * This is useful when type-ids may need to be concatenated. */ -template <typename... Args> constexpr auto type_id_nonull(); +template <typename... Args> +constexpr auto type_id_nonull(); namespace details { @@ -59,17 +62,20 @@ namespace details * 2. Remove 'const' and 'volatile'. * 3. Convert 'char[N]' to 'char*'. */ -template <typename T> struct downcast_members +template <typename T> +struct downcast_members { using type = T; }; -template <typename... Args> struct downcast_members<std::pair<Args...>> +template <typename... Args> +struct downcast_members<std::pair<Args...>> { using type = std::pair<utility::array_to_ptr_t< char, std::remove_cv_t<std::remove_reference_t<Args>>>...>; }; -template <typename... Args> struct downcast_members<std::tuple<Args...>> +template <typename... Args> +struct downcast_members<std::tuple<Args...>> { using type = std::tuple<utility::array_to_ptr_t< char, std::remove_cv_t<std::remove_reference_t<Args>>>...>; @@ -87,7 +93,8 @@ using downcast_members_t = typename downcast_members<T>::type; * 2. Remove 'const' and 'volatile'. * 3. Convert 'char[N]' to 'char*'. */ -template <typename T> struct type_id_downcast +template <typename T> +struct type_id_downcast { using type = utility::array_to_ptr_t< char, downcast_members_t<std::remove_cv_t<std::remove_reference_t<T>>>>; @@ -118,7 +125,8 @@ struct undefined_type_id * A tuple_type_id must be one or more characters. The C1 template param * ensures at least one is present. */ -template <char C1, char... C> struct tuple_type_id +template <char C1, char... C> +struct tuple_type_id { /* This version check is required because a fix for auto is in 5.2+. @@ -138,7 +146,8 @@ template <char C1, char... C> struct tuple_type_id * * @tparam T - The type to get the dbus type character(s) for. */ -template <typename T> constexpr auto type_id_single(); +template <typename T> +constexpr auto type_id_single(); /** @fn type_id_multiple() * @brief Get a tuple containing the dbus type characters for a sequence of @@ -147,7 +156,8 @@ template <typename T> constexpr auto type_id_single(); * @tparam T - The first type to get the dbus type character(s) for. * @tparam ...Args - The remaining types. */ -template <typename T, typename... Args> constexpr auto type_id_multiple(); +template <typename T, typename... Args> +constexpr auto type_id_multiple(); /** @struct type_id * @brief Defined dbus type tuple for a C++ type. @@ -162,48 +172,62 @@ struct type_id : public undefined_type_id { }; // Specializations for built-in types. -template <> struct type_id<bool> : tuple_type_id<SD_BUS_TYPE_BOOLEAN> +template <> +struct type_id<bool> : tuple_type_id<SD_BUS_TYPE_BOOLEAN> { }; -template <> struct type_id<uint8_t> : tuple_type_id<SD_BUS_TYPE_BYTE> +template <> +struct type_id<uint8_t> : tuple_type_id<SD_BUS_TYPE_BYTE> { }; // int8_t isn't supported by dbus. -template <> struct type_id<uint16_t> : tuple_type_id<SD_BUS_TYPE_UINT16> +template <> +struct type_id<uint16_t> : tuple_type_id<SD_BUS_TYPE_UINT16> { }; -template <> struct type_id<int16_t> : tuple_type_id<SD_BUS_TYPE_INT16> +template <> +struct type_id<int16_t> : tuple_type_id<SD_BUS_TYPE_INT16> { }; -template <> struct type_id<uint32_t> : tuple_type_id<SD_BUS_TYPE_UINT32> +template <> +struct type_id<uint32_t> : tuple_type_id<SD_BUS_TYPE_UINT32> { }; -template <> struct type_id<int32_t> : tuple_type_id<SD_BUS_TYPE_INT32> +template <> +struct type_id<int32_t> : tuple_type_id<SD_BUS_TYPE_INT32> { }; -template <> struct type_id<uint64_t> : tuple_type_id<SD_BUS_TYPE_UINT64> +template <> +struct type_id<uint64_t> : tuple_type_id<SD_BUS_TYPE_UINT64> { }; -template <> struct type_id<int64_t> : tuple_type_id<SD_BUS_TYPE_INT64> +template <> +struct type_id<int64_t> : tuple_type_id<SD_BUS_TYPE_INT64> { }; // float isn't supported by dbus. -template <> struct type_id<double> : tuple_type_id<SD_BUS_TYPE_DOUBLE> +template <> +struct type_id<double> : tuple_type_id<SD_BUS_TYPE_DOUBLE> { }; -template <> struct type_id<const char*> : tuple_type_id<SD_BUS_TYPE_STRING> +template <> +struct type_id<const char*> : tuple_type_id<SD_BUS_TYPE_STRING> { }; -template <> struct type_id<char*> : tuple_type_id<SD_BUS_TYPE_STRING> +template <> +struct type_id<char*> : tuple_type_id<SD_BUS_TYPE_STRING> { }; -template <> struct type_id<std::string> : tuple_type_id<SD_BUS_TYPE_STRING> +template <> +struct type_id<std::string> : tuple_type_id<SD_BUS_TYPE_STRING> { }; -template <> struct type_id<object_path> : tuple_type_id<SD_BUS_TYPE_OBJECT_PATH> +template <> +struct type_id<object_path> : tuple_type_id<SD_BUS_TYPE_OBJECT_PATH> { }; -template <> struct type_id<signature> : tuple_type_id<SD_BUS_TYPE_SIGNATURE> +template <> +struct type_id<signature> : tuple_type_id<SD_BUS_TYPE_SIGNATURE> { }; @@ -216,7 +240,8 @@ struct type_id<T, std::enable_if_t<utility::has_const_iterator<T>::value>> type_id<type_id_downcast_t<typename T::value_type>>::value); }; -template <typename T1, typename T2> struct type_id<std::pair<T1, T2>> +template <typename T1, typename T2> +struct type_id<std::pair<T1, T2>> { static constexpr auto value = std::tuple_cat(tuple_type_id<SD_BUS_TYPE_DICT_ENTRY_BEGIN>::value, @@ -225,7 +250,8 @@ template <typename T1, typename T2> struct type_id<std::pair<T1, T2>> tuple_type_id<SD_BUS_TYPE_DICT_ENTRY_END>::value); }; -template <typename... Args> struct type_id<std::tuple<Args...>> +template <typename... Args> +struct type_id<std::tuple<Args...>> { static constexpr auto value = std::tuple_cat(tuple_type_id<SD_BUS_TYPE_STRUCT_BEGIN>::value, @@ -238,33 +264,38 @@ struct type_id<variant<Args...>> : tuple_type_id<SD_BUS_TYPE_VARIANT> { }; -template <> struct type_id<void> +template <> +struct type_id<void> { constexpr static auto value = std::make_tuple('\0'); }; -template <typename T> constexpr auto type_id_single() +template <typename T> +constexpr auto type_id_single() { static_assert(!std::is_base_of<undefined_type_id, type_id<T>>::value, "No dbus type conversion provided for type."); return type_id<T>::value; } -template <typename T, typename... Args> constexpr auto type_id_multiple() +template <typename T, typename... Args> +constexpr auto type_id_multiple() { return std::tuple_cat(type_id_single<T>(), type_id_single<Args>()...); } } // namespace details -template <typename... Args> constexpr auto type_id() +template <typename... Args> +constexpr auto type_id() { return std::tuple_cat( details::type_id_multiple<details::type_id_downcast_t<Args>...>(), std::make_tuple('\0') /* null terminator for C-string */); } -template <typename... Args> constexpr auto type_id_nonull() +template <typename... Args> +constexpr auto type_id_nonull() { return details::type_id_multiple<details::type_id_downcast_t<Args>...>(); } diff --git a/sdbusplus/server/bindings.hpp b/sdbusplus/server/bindings.hpp index af57845..b5429de 100644 --- a/sdbusplus/server/bindings.hpp +++ b/sdbusplus/server/bindings.hpp @@ -17,7 +17,8 @@ namespace details * can be inserted into a message. This template provides a general no-op * implementation for all other types. */ -template <typename T> T&& convertForMessage(T&& t) +template <typename T> +T&& convertForMessage(T&& t) { return std::forward<T>(t); } diff --git a/sdbusplus/server/object.hpp b/sdbusplus/server/object.hpp index 499f4e8..7aaeaa5 100644 --- a/sdbusplus/server/object.hpp +++ b/sdbusplus/server/object.hpp @@ -20,7 +20,8 @@ namespace details * These allow an object to group multiple dbus interface bindings into a * single class. */ -template <class T, class... Rest> struct compose_impl : T, compose_impl<Rest...> +template <class T, class... Rest> +struct compose_impl : T, compose_impl<Rest...> { compose_impl(bus::bus& bus, const char* path) : T(bus, path), compose_impl<Rest...>(bus, path) @@ -29,7 +30,8 @@ template <class T, class... Rest> struct compose_impl : T, compose_impl<Rest...> }; /** Specialization for single element. */ -template <class T> struct compose_impl<T> : T +template <class T> +struct compose_impl<T> : T { compose_impl(bus::bus& bus, const char* path) : T(bus, path) { @@ -37,7 +39,8 @@ template <class T> struct compose_impl<T> : T }; /** Default compose operation for variadic arguments. */ -template <class... Args> struct compose : compose_impl<Args...> +template <class... Args> +struct compose : compose_impl<Args...> { compose(bus::bus& bus, const char* path) : compose_impl<Args...>(bus, path) { @@ -45,7 +48,8 @@ template <class... Args> struct compose : compose_impl<Args...> }; /** Specialization for zero variadic arguments. */ -template <> struct compose<> +template <> +struct compose<> { compose(bus::bus& bus, const char* path) { @@ -66,7 +70,8 @@ template <> struct compose<> * 'sd_bus_emit_object_removed' signals are emitted. * */ -template <class... Args> struct object : details::compose<Args...> +template <class... Args> +struct object : details::compose<Args...> { /* Define all of the basic class operations: * Not allowed: @@ -139,7 +144,8 @@ template <class... Args> struct object : details::compose<Args...> } // namespace object -template <class... Args> using object_t = object::object<Args...>; +template <class... Args> +using object_t = object::object<Args...>; } // namespace server } // namespace sdbusplus diff --git a/sdbusplus/server/transaction.hpp b/sdbusplus/server/transaction.hpp index f6d9234..87af07b 100644 --- a/sdbusplus/server/transaction.hpp +++ b/sdbusplus/server/transaction.hpp @@ -46,7 +46,8 @@ namespace std { /** @ brief Overload of std::hash for sdbusplus::bus::bus */ -template <> struct hash<sdbusplus::bus::bus> +template <> +struct hash<sdbusplus::bus::bus> { auto operator()(sdbusplus::bus::bus& b) const { @@ -56,7 +57,8 @@ template <> struct hash<sdbusplus::bus::bus> }; /** @ brief Overload of std::hash for sdbusplus::message::message */ -template <> struct hash<sdbusplus::message::message> +template <> +struct hash<sdbusplus::message::message> { auto operator()(sdbusplus::message::message& m) const { @@ -66,7 +68,8 @@ template <> struct hash<sdbusplus::message::message> }; /** @ brief Overload of std::hash for Transaction */ -template <> struct hash<sdbusplus::server::transaction::Transaction> +template <> +struct hash<sdbusplus::server::transaction::Transaction> { auto operator()(sdbusplus::server::transaction::Transaction const& t) const { @@ -80,7 +83,8 @@ template <> struct hash<sdbusplus::server::transaction::Transaction> }; /** @ brief Overload of std::hash for details::Transaction */ -template <> struct hash<sdbusplus::server::transaction::details::Transaction> +template <> +struct hash<sdbusplus::server::transaction::details::Transaction> { auto operator()( sdbusplus::server::transaction::details::Transaction const& t) const diff --git a/sdbusplus/utility/container_traits.hpp b/sdbusplus/utility/container_traits.hpp index e778d17..8783097 100644 --- a/sdbusplus/utility/container_traits.hpp +++ b/sdbusplus/utility/container_traits.hpp @@ -11,7 +11,8 @@ namespace utility * * @value A value as to whether or not the type supports iteration */ -template <typename T> struct has_const_iterator +template <typename T> +struct has_const_iterator { private: typedef char yes; @@ -22,7 +23,8 @@ template <typename T> struct has_const_iterator template <typename C> static constexpr yes test(typename C::const_iterator*); - template <typename C> static constexpr no test(...); + template <typename C> + static constexpr no test(...); public: static constexpr bool value = sizeof(test<T>(0)) == sizeof(yes); @@ -34,7 +36,8 @@ template <typename T> struct has_const_iterator * * @value A value as to whether or not the type has an emplace method */ -template <typename T> struct has_emplace_method +template <typename T> +struct has_emplace_method { private: struct dummy @@ -45,7 +48,8 @@ template <typename T> struct has_emplace_method static constexpr auto test(P* p) -> decltype(std::declval<C>().emplace(*p), std::true_type()); - template <typename, typename> static std::false_type test(...); + template <typename, typename> + static std::false_type test(...); public: static constexpr bool value = @@ -59,7 +63,8 @@ template <typename T> struct has_emplace_method * * @value A value as to whether or not the type has an emplace_back method */ -template <typename T> struct has_emplace_back_method +template <typename T> +struct has_emplace_back_method { private: struct dummy @@ -70,7 +75,8 @@ template <typename T> struct has_emplace_back_method static constexpr auto test(P* p) -> decltype(std::declval<C>().emplace_back(*p), std::true_type()); - template <typename, typename> static std::false_type test(...); + template <typename, typename> + static std::false_type test(...); public: static constexpr bool value = diff --git a/sdbusplus/utility/read_into_tuple.hpp b/sdbusplus/utility/read_into_tuple.hpp index 30dbea5..e2875b6 100644 --- a/sdbusplus/utility/read_into_tuple.hpp +++ b/sdbusplus/utility/read_into_tuple.hpp @@ -30,7 +30,8 @@ constexpr auto index_apply_impl(F f, std::index_sequence<Is...>) { return f(std::integral_constant<size_t, Is>{}...); } -template <size_t N, class F> constexpr auto index_apply(F f) +template <size_t N, class F> +constexpr auto index_apply(F f) { return index_apply_impl(f, std::make_index_sequence<N>{}); } diff --git a/sdbusplus/utility/type_traits.hpp b/sdbusplus/utility/type_traits.hpp index 9ba0180..fb6f0b6 100644 --- a/sdbusplus/utility/type_traits.hpp +++ b/sdbusplus/utility/type_traits.hpp @@ -23,7 +23,8 @@ using array_to_ptr_t = typename std::conditional_t< // Small helper class for stripping off the error code from the function // argument definitions so unpack can be called appropriately -template <typename T> struct strip_first_arg +template <typename T> +struct strip_first_arg { }; @@ -34,7 +35,8 @@ struct strip_first_arg<std::tuple<FirstArg, Rest...>> }; // matching helper class to only return the first type -template <typename T> struct get_first_arg +template <typename T> +struct get_first_arg { }; @@ -45,11 +47,13 @@ struct get_first_arg<std::tuple<FirstArg, Rest...>> }; // helper class to remove const and reference from types -template <typename T> struct decay_tuple +template <typename T> +struct decay_tuple { }; -template <typename... Args> struct decay_tuple<std::tuple<Args...>> +template <typename... Args> +struct decay_tuple<std::tuple<Args...>> { using type = std::tuple<typename std::decay<Args>::type...>; }; diff --git a/test/message/append.cpp b/test/message/append.cpp index 6485d99..de40ef6 100644 --- a/test/message/append.cpp +++ b/test/message/append.cpp @@ -42,7 +42,8 @@ class AppendTest : public testing::Test nullptr, nullptr, nullptr, nullptr); } - template <typename T> void expect_basic(char type, T val) + template <typename T> + void expect_basic(char type, T val) { EXPECT_CALL(mock, sd_bus_message_append_basic( diff --git a/test/message/read.cpp b/test/message/read.cpp index 07bc984..14da902 100644 --- a/test/message/read.cpp +++ b/test/message/read.cpp @@ -52,7 +52,8 @@ class ReadTest : public testing::Test .WillOnce(Return(ret)); } - template <typename T> void expect_basic(char type, T val) + template <typename T> + void expect_basic(char type, T val) { EXPECT_CALL(mock, sd_bus_message_read_basic(nullptr, type, testing::_)) .WillOnce(DoAll(AssignReadVal<T>(val), Return(0))); diff --git a/test/message/types.cpp b/test/message/types.cpp index a6df2f4..327fe71 100644 --- a/test/message/types.cpp +++ b/test/message/types.cpp @@ -3,7 +3,8 @@ #include <gtest/gtest.h> -template <typename... Args> auto dbus_string(Args&&... args) +template <typename... Args> +auto dbus_string(Args&&... args) { return std::string(sdbusplus::utility::tuple_to_array( sdbusplus::message::types::type_id<Args...>()) |

