restored inline where really needed and use BOOST_ATTRIBUTE_UNUSED macro instead of custom ifdef

This commit is contained in:
Hans Dembinski
2018-07-22 14:49:13 +02:00
parent 8b409b15ce
commit b34b1b1e15
3 changed files with 10 additions and 15 deletions

View File

@@ -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 <typename T>
@@ -120,7 +120,8 @@ std::ostream& operator<<(std::ostream& os, const category<T>& a) {
}
template <>
std::ostream& operator<<(std::ostream& os, const category<std::string>& a) {
inline std::ostream& operator<<(std::ostream& os,
const category<std::string>& a) {
os << "category(";
for (int i = 0; i < a.size(); ++i) {
::boost::histogram::detail::escape(os, a.value(i));

View File

@@ -7,17 +7,14 @@
#ifndef _BOOST_HISTOGRAM_DETAIL_CAT_HPP_
#define _BOOST_HISTOGRAM_DETAIL_CAT_HPP_
#include <boost/config.hpp>
#include <sstream>
#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 <typename T, typename... Ts>
void cat_impl(std::ostringstream& os, const T& t, const Ts&... ts) {

View File

@@ -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
}