From 8f0f6dde9dbea792e34a8bcc9dd5facec99b285d Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 25 Mar 2019 23:16:28 +0000 Subject: [PATCH] Include What You Use --- llarp/util/metrics_types.cpp | 2 -- llarp/util/metrics_types.hpp | 26 +++++++++++++------------- llarp/util/object.hpp | 4 +++- test/test_util.hpp | 1 + 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/llarp/util/metrics_types.cpp b/llarp/util/metrics_types.cpp index efd4b7b77..6d8f0a743 100644 --- a/llarp/util/metrics_types.cpp +++ b/llarp/util/metrics_types.cpp @@ -6,8 +6,6 @@ namespace llarp { namespace metrics { - const char *FormatSpec::DEFAULT_FORMAT = "%f"; - std::ostream & FormatSpec::format(std::ostream &stream, double data, const FormatSpec &format) diff --git a/llarp/util/metrics_types.hpp b/llarp/util/metrics_types.hpp index b553929b5..aacdbc041 100644 --- a/llarp/util/metrics_types.hpp +++ b/llarp/util/metrics_types.hpp @@ -43,13 +43,13 @@ namespace llarp float m_scale; const char *m_format; - static const char *DEFAULT_FORMAT; + static constexpr char DEFAULT_FORMAT[] = "%f"; - FormatSpec() : m_scale(1.0), m_format(DEFAULT_FORMAT) + constexpr FormatSpec() : m_scale(1.0), m_format(DEFAULT_FORMAT) { } - FormatSpec(float scale, const char *format) + constexpr FormatSpec(float scale, const char *format) : m_scale(scale), m_format(format) { } @@ -71,7 +71,7 @@ namespace llarp std::array< Spec, Publication::MaxSize > m_specs; - Format() : m_specs() + constexpr Format() : m_specs() { } @@ -81,13 +81,13 @@ namespace llarp m_specs[static_cast< size_t >(pub)].emplace(spec); } - void + constexpr void clear() { m_specs = decltype(m_specs)(); } - const FormatSpec * + constexpr const FormatSpec * specFor(Publication::Type val) const { const auto &spec = m_specs[static_cast< size_t >(val)]; @@ -158,7 +158,7 @@ namespace llarp const Category *m_category; CategoryContainer *m_nextCategory; - void + constexpr void clear() { m_enabled = false; @@ -261,33 +261,33 @@ namespace llarp const Description *m_description; public: - Id() : m_description(nullptr) + constexpr Id() : m_description(nullptr) { } - Id(const Description *description) : m_description(description) + constexpr Id(const Description *description) : m_description(description) { } - const Description *& + constexpr const Description *& description() { return m_description; } - const Description *const & + constexpr const Description *const & description() const { return m_description; } - constexpr bool + bool valid() const noexcept { return m_description != nullptr; } - explicit constexpr operator bool() const noexcept + explicit operator bool() const noexcept { return valid(); } diff --git a/llarp/util/object.hpp b/llarp/util/object.hpp index f4dc54432..1981da498 100644 --- a/llarp/util/object.hpp +++ b/llarp/util/object.hpp @@ -1,9 +1,11 @@ #ifndef LLARP_OBJECT_HPP #define LLARP_OBJECT_HPP -#include #include +#include +#include + namespace llarp { namespace object diff --git a/test/test_util.hpp b/test/test_util.hpp index 8a7360135..aeb0e7494 100644 --- a/test/test_util.hpp +++ b/test/test_util.hpp @@ -5,6 +5,7 @@ #include #include +#include namespace llarp {