From b34b1b1e154cdfd8732017de406e216ee3c913d4 Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Sun, 22 Jul 2018 14:49:13 +0200 Subject: [PATCH] restored inline where really needed and use BOOST_ATTRIBUTE_UNUSED macro instead of custom ifdef --- include/boost/histogram/axis/ostream_operators.hpp | 9 +++++---- include/boost/histogram/detail/cat.hpp | 7 ++----- include/boost/histogram/detail/utility.hpp | 9 +++------ 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/include/boost/histogram/axis/ostream_operators.hpp b/include/boost/histogram/axis/ostream_operators.hpp index 63928e6b..4ab71b51 100644 --- a/include/boost/histogram/axis/ostream_operators.hpp +++ b/include/boost/histogram/axis/ostream_operators.hpp @@ -20,9 +20,9 @@ namespace histogram { namespace axis { namespace detail { -string_view to_string(const transform::identity&) { return {}; } -string_view to_string(const transform::log&) { return {"_log", 4}; } -string_view to_string(const transform::sqrt&) { return {"_sqrt", 5}; } +inline string_view to_string(const transform::identity&) { return {}; } +inline string_view to_string(const transform::log&) { return {"_log", 4}; } +inline string_view to_string(const transform::sqrt&) { return {"_sqrt", 5}; } } // namespace detail template @@ -120,7 +120,8 @@ std::ostream& operator<<(std::ostream& os, const category& a) { } template <> -std::ostream& operator<<(std::ostream& os, const category& a) { +inline std::ostream& operator<<(std::ostream& os, + const category& a) { os << "category("; for (int i = 0; i < a.size(); ++i) { ::boost::histogram::detail::escape(os, a.value(i)); diff --git a/include/boost/histogram/detail/cat.hpp b/include/boost/histogram/detail/cat.hpp index 55f9ed87..42bda03b 100644 --- a/include/boost/histogram/detail/cat.hpp +++ b/include/boost/histogram/detail/cat.hpp @@ -7,17 +7,14 @@ #ifndef _BOOST_HISTOGRAM_DETAIL_CAT_HPP_ #define _BOOST_HISTOGRAM_DETAIL_CAT_HPP_ +#include #include -#ifdef _MSC_VER -#define __attribute__(A) // ignore GCC extension -#endif - namespace boost { namespace histogram { namespace detail { namespace { -__attribute__((unused)) void cat_impl(std::ostringstream&) {} +BOOST_ATTRIBUTE_UNUSED inline void cat_impl(std::ostringstream&) {} template void cat_impl(std::ostringstream& os, const T& t, const Ts&... ts) { diff --git a/include/boost/histogram/detail/utility.hpp b/include/boost/histogram/detail/utility.hpp index 111e3923..e640fb0c 100644 --- a/include/boost/histogram/detail/utility.hpp +++ b/include/boost/histogram/detail/utility.hpp @@ -27,7 +27,7 @@ namespace detail { // two_pi can be found in boost/math, but it is defined here to reduce deps constexpr double two_pi = 6.283185307179586; -void escape(std::ostream& os, const string_view s) { +inline void escape(std::ostream& os, const string_view s) { os << '\''; for (auto sit = s.begin(); sit != s.end(); ++sit) { if (*sit == '\'' && (sit == s.begin() || *(sit - 1) != '\\')) { @@ -41,15 +41,12 @@ void escape(std::ostream& os, const string_view s) { // the following is highly optimized code that runs in a hot loop; // please measure the performance impact of changes -void lin(std::size_t& out, std::size_t& stride, const int axis_size, - const int axis_shape, int j) noexcept { +inline void lin(std::size_t& out, std::size_t& stride, const int axis_size, + const int axis_shape, int j) noexcept { BOOST_ASSERT_MSG(stride == 0 || (-1 <= j && j <= axis_size), "index must be in bounds for this algorithm"); j += (j < 0) * (axis_size + 2); // wrap around if j < 0 out += j * stride; -#ifndef _MSC_VER -#pragma GCC diagnostic ignored "-Wstrict-overflow" -#endif stride *= (j < axis_shape) * axis_shape; // stride == 0 indicates out-of-range }