remove boost.assert and cleanup boost.config

This commit is contained in:
Hans Dembinski 2020-06-08 00:41:12 +02:00 committed by GitHub
parent 8ecaf89c3a
commit a819ef53bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 192 additions and 213 deletions

View File

@ -54,5 +54,5 @@ test_script:
## Uncomment the following to stop VM and enable interactive login.
## Instructions how to log into the Appveyor VM are automatically printed.
on_failure:
- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
# on_failure:
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

View File

@ -14,7 +14,6 @@ target_include_directories(boost_histogram INTERFACE include)
target_compile_features(boost_histogram INTERFACE cxx_std_14)
target_link_libraries(boost_histogram
INTERFACE
Boost::assert
Boost::config
Boost::core
Boost::mp11
@ -50,7 +49,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(BUILD_TESTING OFF) # do not build tests of dependencies
boost_fetch(boostorg/assert TAG develop EXCLUDE_FROM_ALL)
boost_fetch(boostorg/assert TAG develop EXCLUDE_FROM_ALL) # needed by core
boost_fetch(boostorg/config TAG develop EXCLUDE_FROM_ALL)
boost_fetch(boostorg/core TAG develop EXCLUDE_FROM_ALL)
boost_fetch(boostorg/mp11 TAG develop EXCLUDE_FROM_ALL)

View File

@ -10,10 +10,10 @@
#include "../test/throw_exception.hpp"
#include "generator.hpp"
#include <boost/assert.hpp>
#include <cassert>
struct assert_check {
assert_check() {
BOOST_ASSERT(false); // don't run with asserts enabled
assert(false); // don't run with asserts enabled
}
} _;

View File

@ -12,10 +12,10 @@
#include "../test/utility_histogram.hpp"
#include "generator.hpp"
#include <boost/assert.hpp>
#include <cassert>
struct assert_check {
assert_check() {
BOOST_ASSERT(false); // don't run with asserts enabled
assert(false); // don't run with asserts enabled
}
} _;

View File

@ -10,10 +10,10 @@
#include "../test/throw_exception.hpp"
#include "generator.hpp"
#include <boost/assert.hpp>
#include <cassert>
struct assert_check {
assert_check() {
BOOST_ASSERT(false); // don't run with asserts enabled
assert(false); // don't run with asserts enabled
}
} _;

View File

@ -11,10 +11,10 @@
#include <benchmark/benchmark.h>
#include "generator.hpp"
#include <boost/assert.hpp>
#include <cassert>
struct assert_check {
assert_check() {
BOOST_ASSERT(false); // don't run with asserts enabled
assert(false); // don't run with asserts enabled
}
} _;

View File

@ -15,10 +15,10 @@
#include <vector>
#include "../test/throw_exception.hpp"
#include <boost/assert.hpp>
#include <cassert>
struct assert_check {
assert_check() {
BOOST_ASSERT(false); // don't run with asserts enabled
assert(false); // don't run with asserts enabled
}
} _;

View File

@ -18,10 +18,10 @@
#include <vector>
#include "../test/throw_exception.hpp"
#include <boost/assert.hpp>
#include <cassert>
struct assert_check {
assert_check() {
BOOST_ASSERT(false); // don't run with asserts enabled
assert(false); // don't run with asserts enabled
}
} _;

View File

@ -7,10 +7,10 @@
#ifndef BOOST_HISTOGRAM_ACCUMULATORS_MEAN_HPP
#define BOOST_HISTOGRAM_ACCUMULATORS_MEAN_HPP
#include <boost/assert.hpp>
#include <boost/core/nvp.hpp>
#include <boost/histogram/fwd.hpp> // for mean<>
#include <boost/throw_exception.hpp>
#include <cassert>
#include <stdexcept>
#include <type_traits>

View File

@ -7,10 +7,10 @@
#ifndef BOOST_HISTOGRAM_ACCUMULATORS_WEIGHTED_MEAN_HPP
#define BOOST_HISTOGRAM_ACCUMULATORS_WEIGHTED_MEAN_HPP
#include <boost/assert.hpp>
#include <boost/core/nvp.hpp>
#include <boost/histogram/fwd.hpp> // for weighted_mean<>
#include <boost/histogram/weight.hpp>
#include <cassert>
#include <type_traits>
namespace boost {

View File

@ -7,7 +7,6 @@
#ifndef BOOST_HISTOGRAM_ALGORITHM_REDUCE_HPP
#define BOOST_HISTOGRAM_ALGORITHM_REDUCE_HPP
#include <boost/assert.hpp>
#include <boost/histogram/axis/traits.hpp>
#include <boost/histogram/detail/axes.hpp>
#include <boost/histogram/detail/make_default.hpp>
@ -17,6 +16,7 @@
#include <boost/histogram/indexed.hpp>
#include <boost/histogram/unsafe_access.hpp>
#include <boost/throw_exception.hpp>
#include <cassert>
#include <cmath>
#include <initializer_list>
#include <stdexcept>

View File

@ -9,13 +9,13 @@
#ifndef BOOST_HISTOGRAM_AXIS_OSTREAM_HPP
#define BOOST_HISTOGRAM_AXIS_OSTREAM_HPP
#include <boost/assert.hpp>
#include <boost/histogram/axis/regular.hpp>
#include <boost/histogram/detail/counting_streambuf.hpp>
#include <boost/histogram/detail/priority.hpp>
#include <boost/histogram/detail/type_name.hpp>
#include <boost/histogram/fwd.hpp>
#include <boost/throw_exception.hpp>
#include <cassert>
#include <iomanip>
#include <iosfwd>
#include <sstream>

View File

@ -7,7 +7,6 @@
#ifndef BOOST_HISTOGRAM_AXIS_REGULAR_HPP
#define BOOST_HISTOGRAM_AXIS_REGULAR_HPP
#include <boost/assert.hpp>
#include <boost/core/nvp.hpp>
#include <boost/histogram/axis/interval_view.hpp>
#include <boost/histogram/axis/iterator.hpp>
@ -19,6 +18,7 @@
#include <boost/histogram/fwd.hpp>
#include <boost/mp11/utility.hpp>
#include <boost/throw_exception.hpp>
#include <cassert>
#include <cmath>
#include <limits>
#include <stdexcept>
@ -280,7 +280,7 @@ public:
regular(const regular& src, index_type begin, index_type end, unsigned merge)
: regular(src.transform(), (end - begin) / merge, src.value(begin), src.value(end),
src.metadata()) {
BOOST_ASSERT((end - begin) % merge == 0);
assert((end - begin) % merge == 0);
if (options_type::test(option::circular) && !(begin == 0 && end == src.size()))
BOOST_THROW_EXCEPTION(std::invalid_argument("cannot shrink circular axis"));
}
@ -310,7 +310,7 @@ public:
/// Returns index and shift (if axis has grown) for the passed argument.
std::pair<index_type, index_type> update(value_type x) noexcept {
BOOST_ASSERT(options_type::test(option::growth));
assert(options_type::test(option::growth));
const auto z = (this->forward(x / unit_type{}) - min_) / delta_;
if (z < 1) { // don't use i here!
if (z >= 0) {

View File

@ -7,7 +7,6 @@
#ifndef BOOST_HISTOGRAM_AXIS_TRAITS_HPP
#define BOOST_HISTOGRAM_AXIS_TRAITS_HPP
#include <boost/core/ignore_unused.hpp>
#include <boost/histogram/axis/option.hpp>
#include <boost/histogram/detail/args_type.hpp>
#include <boost/histogram/detail/detect.hpp>
@ -254,7 +253,7 @@ struct is_ordered;
*/
template <class Axis>
constexpr unsigned options(const Axis& axis) noexcept {
boost::ignore_unused(axis);
(void)axis;
return get_options<Axis>::value;
}
@ -272,7 +271,7 @@ unsigned options(const variant<Ts...>& axis) noexcept {
*/
template <class Axis>
constexpr bool inclusive(const Axis& axis) noexcept {
boost::ignore_unused(axis);
(void)axis;
return is_inclusive<Axis>::value;
}
@ -290,7 +289,7 @@ bool inclusive(const variant<Ts...>& axis) noexcept {
*/
template <class Axis>
constexpr bool ordered(const Axis& axis) noexcept {
boost::ignore_unused(axis);
(void)axis;
return is_ordered<Axis>::value;
}
@ -308,7 +307,7 @@ bool ordered(const variant<Ts...>& axis) noexcept {
*/
template <class Axis>
constexpr bool continuous(const Axis& axis) noexcept {
boost::ignore_unused(axis);
(void)axis;
return is_continuous<Axis>::value;
}
@ -341,7 +340,7 @@ template <class Axis>
decltype(auto) metadata(Axis&& axis) noexcept {
return detail::static_if<detail::has_method_metadata<std::decay_t<Axis>>>(
[](auto&& a) -> decltype(auto) { return a.metadata(); },
[](auto &&) -> axis::null_type& { return detail::null_value; },
[](auto&&) -> axis::null_type& { return detail::null_value; },
std::forward<Axis>(axis));
}
@ -403,7 +402,7 @@ axis::index_type index(const variant<Ts...>& axis, const U& value) {
*/
template <class Axis>
constexpr unsigned rank(const Axis& axis) {
boost::ignore_unused(axis);
(void)axis;
using T = value_type<Axis>;
// cannot use mp_eval_or since T could be a fixed-sized sequence
return mp11::mp_eval_if_not<detail::is_tuple<T>, mp11::mp_size_t<1>, mp11::mp_size,

View File

@ -8,7 +8,6 @@
#define BOOST_HISTOGRAM_AXIS_VARIABLE_HPP
#include <algorithm>
#include <boost/assert.hpp>
#include <boost/core/nvp.hpp>
#include <boost/histogram/axis/interval_view.hpp>
#include <boost/histogram/axis/iterator.hpp>
@ -21,6 +20,7 @@
#include <boost/histogram/detail/replace_type.hpp>
#include <boost/histogram/fwd.hpp>
#include <boost/throw_exception.hpp>
#include <cassert>
#include <cmath>
#include <limits>
#include <memory>
@ -121,7 +121,7 @@ public:
/// Constructor used by algorithm::reduce to shrink and rebin (not for users).
variable(const variable& src, index_type begin, index_type end, unsigned merge)
: metadata_base(src), vec_(src.get_allocator()) {
BOOST_ASSERT((end - begin) % merge == 0);
assert((end - begin) % merge == 0);
if (options_type::test(option::circular) && !(begin == 0 && end == src.size()))
BOOST_THROW_EXCEPTION(std::invalid_argument("cannot shrink circular axis"));
vec_.reserve((end - begin) / merge);

View File

@ -8,9 +8,6 @@
#define BOOST_HISTOGRAM_DETAIL_AXES_HPP
#include <array>
#include <boost/assert.hpp>
#include <boost/config/workaround.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/core/nvp.hpp>
#include <boost/histogram/axis/traits.hpp>
#include <boost/histogram/axis/variant.hpp>
@ -21,6 +18,7 @@
#include <boost/histogram/detail/relaxed_tuple_size.hpp>
#include <boost/histogram/detail/static_if.hpp>
#include <boost/histogram/detail/sub_array.hpp>
#include <boost/histogram/detail/try_cast.hpp>
#include <boost/histogram/fwd.hpp>
#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/integer_sequence.hpp>
@ -28,6 +26,7 @@
#include <boost/mp11/tuple.hpp>
#include <boost/mp11/utility.hpp>
#include <boost/throw_exception.hpp>
#include <cassert>
#include <initializer_list>
#include <iterator>
#include <stdexcept>
@ -58,25 +57,16 @@ void for_each_axis(T&& t, Unary&& p) {
// merge if a and b are discrete and growing
struct axis_merger {
template <class T>
T operator()(const T& a, const T& b) {
template <class T, class U>
T operator()(const T& a, const U& u) {
const T* bp = ptr_cast<T>(&u);
if (!bp) BOOST_THROW_EXCEPTION(std::invalid_argument("axes not mergable"));
using O = axis::traits::get_options<T>;
constexpr bool discrete_and_growing =
axis::traits::is_continuous<T>::value == false && O::test(axis::option::growth);
return impl(mp11::mp_bool<discrete_and_growing>{}, a, b);
return impl(mp11::mp_bool<discrete_and_growing>{}, a, *bp);
}
#if BOOST_WORKAROUND(BOOST_MSVC, >= 0)
#pragma warning(disable : 4702) // fixing warning would reduce code readability a lot
#endif
template <class T, class U>
T operator()(const T& a, const U&) {
return BOOST_THROW_EXCEPTION(std::invalid_argument("axes not mergable")), a;
}
#if BOOST_WORKAROUND(BOOST_MSVC, >= 0)
#pragma warning(default : 4702)
#endif
template <class T>
T impl(std::false_type, const T& a, const T& b) {
if (!relaxed_equal{}(a, b))
@ -238,8 +228,8 @@ template <class T, class U, std::size_t... Is>
bool axes_equal_impl(const T& t, const U& u, mp11::index_sequence<Is...>) noexcept {
bool result = true;
// operator folding emulation
ignore_unused(std::initializer_list<bool>{
(result &= relaxed_equal{}(std::get<Is>(t), std::get<Is>(u)))...});
(void)std::initializer_list<bool>{
(result &= relaxed_equal{}(std::get<Is>(t), std::get<Is>(u)))...};
return result;
}

View File

@ -8,7 +8,6 @@
#define BOOST_HISTOGRAM_DETAIL_FILL_HPP
#include <algorithm>
#include <boost/assert.hpp>
#include <boost/config/workaround.hpp>
#include <boost/histogram/axis/traits.hpp>
#include <boost/histogram/axis/variant.hpp>
@ -24,6 +23,7 @@
#include <boost/mp11/integral.hpp>
#include <boost/mp11/tuple.hpp>
#include <boost/mp11/utility.hpp>
#include <cassert>
#include <mutex>
#include <tuple>
#include <type_traits>
@ -195,7 +195,7 @@ void fill_storage_2(mp11::mp_int<-1>, mp11::mp_int<-1>, T&& t, const U&) noexcep
template <class IW, class IS, class Storage, class Index, class Args>
auto fill_storage(IW, IS, Storage& s, const Index idx, const Args& a) noexcept {
if (is_valid(idx)) {
BOOST_ASSERT(idx < s.size());
assert(idx < s.size());
fill_storage_2(IW{}, IS{}, s[idx], a);
return s.begin() + idx;
}

View File

@ -8,8 +8,6 @@
#define BOOST_HISTOGRAM_DETAIL_FILL_N_HPP
#include <algorithm>
#include <boost/assert.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/histogram/axis/option.hpp>
#include <boost/histogram/axis/traits.hpp>
#include <boost/histogram/detail/axes.hpp>
@ -26,6 +24,7 @@
#include <boost/mp11/utility.hpp>
#include <boost/throw_exception.hpp>
#include <boost/variant2/variant.hpp>
#include <cassert>
#include <initializer_list>
#include <stdexcept>
#include <type_traits>
@ -157,22 +156,22 @@ void fill_n_indices(Index* indices, const std::size_t start, const std::size_t s
template <class S, class Index, class... Ts>
void fill_n_storage(S& s, const Index idx, Ts&&... p) noexcept {
if (is_valid(idx)) {
BOOST_ASSERT(idx < s.size());
assert(idx < s.size());
fill_storage_element(s[idx], *p.first...);
}
// operator folding emulation
ignore_unused(std::initializer_list<int>{(p.second ? (++p.first, 0) : 0)...});
(void)std::initializer_list<int>{(p.second ? (++p.first, 0) : 0)...};
}
template <class S, class Index, class T, class... Ts>
void fill_n_storage(S& s, const Index idx, weight_type<T>&& w, Ts&&... ps) noexcept {
if (is_valid(idx)) {
BOOST_ASSERT(idx < s.size());
assert(idx < s.size());
fill_storage_element(s[idx], weight(*w.value.first), *ps.first...);
}
if (w.value.second) ++w.value.first;
// operator folding emulation
ignore_unused(std::initializer_list<int>{(ps.second ? (++ps.first, 0) : 0)...});
(void)std::initializer_list<int>{(ps.second ? (++ps.first, 0) : 0)...};
}
// general Nd treatment
@ -256,7 +255,7 @@ std::size_t get_total_size(const A& axes, const dtl::span<const T, N>& values) {
// supported cases (T = value type; CT = containter of T; V<T, CT, ...> = variant):
// - span<CT, N>: for any histogram, N == rank
// - span<V<T, CT>, N>: for any histogram, N == rank
BOOST_ASSERT(axes_rank(axes) == values.size());
assert(axes_rank(axes) == values.size());
constexpr auto unset = static_cast<std::size_t>(-1);
std::size_t size = unset;
for_each_axis(axes, [&size, vit = values.begin()](const auto& ax) mutable {

View File

@ -8,8 +8,6 @@
#define BOOST_HISTOGRAM_DETAIL_INDEX_TRANSLATOR_HPP
#include <algorithm>
#include <boost/assert.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/histogram/axis/traits.hpp>
#include <boost/histogram/axis/variant.hpp>
#include <boost/histogram/detail/relaxed_equal.hpp>
@ -18,6 +16,7 @@
#include <boost/histogram/multi_index.hpp>
#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/integer_sequence.hpp>
#include <cassert>
#include <initializer_list>
#include <tuple>
#include <vector>
@ -60,7 +59,7 @@ struct index_translator {
template <class T>
static index_type translate(const T& dst, const T& src, index_type i) noexcept {
BOOST_ASSERT(axis::traits::is_continuous<T>::value == false); // LCOV_EXCL_LINE: unreachable
assert(axis::traits::is_continuous<T>::value == false); // LCOV_EXCL_LINE: unreachable
return dst.index(src.value(i));
}

View File

@ -7,13 +7,13 @@
#ifndef BOOST_HISTOGRAM_DETAIL_LARGE_INT_HPP
#define BOOST_HISTOGRAM_DETAIL_LARGE_INT_HPP
#include <boost/assert.hpp>
#include <boost/histogram/detail/operators.hpp>
#include <boost/histogram/detail/safe_comparison.hpp>
#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/function.hpp>
#include <boost/mp11/list.hpp>
#include <boost/mp11/utility.hpp>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <limits>
@ -68,7 +68,7 @@ struct large_int : totally_ordered<large_int<Allocator>, large_int<Allocator>>,
}
large_int& operator++() {
BOOST_ASSERT(data.size() > 0u);
assert(data.size() > 0u);
std::size_t i = 0;
while (!safe_increment(data[i])) {
data[i] = 0;
@ -114,7 +114,7 @@ struct large_int : totally_ordered<large_int<Allocator>, large_int<Allocator>>,
}
large_int& operator+=(std::uint64_t o) {
BOOST_ASSERT(data.size() > 0u);
assert(data.size() > 0u);
if (safe_radd(data[0], o)) return *this;
add_remainder(data[0], o);
// carry the one, data may grow several times
@ -129,7 +129,7 @@ struct large_int : totally_ordered<large_int<Allocator>, large_int<Allocator>>,
}
explicit operator double() const noexcept {
BOOST_ASSERT(data.size() > 0u);
assert(data.size() > 0u);
double result = static_cast<double>(data[0]);
std::size_t i = 0;
while (++i < data.size())
@ -138,11 +138,11 @@ struct large_int : totally_ordered<large_int<Allocator>, large_int<Allocator>>,
}
bool operator<(const large_int& o) const noexcept {
BOOST_ASSERT(data.size() > 0u);
BOOST_ASSERT(o.data.size() > 0u);
assert(data.size() > 0u);
assert(o.data.size() > 0u);
// no leading zeros allowed
BOOST_ASSERT(data.size() == 1 || data.back() > 0u);
BOOST_ASSERT(o.data.size() == 1 || o.data.back() > 0u);
assert(data.size() == 1 || data.back() > 0u);
assert(o.data.size() == 1 || o.data.back() > 0u);
if (data.size() < o.data.size()) return true;
if (data.size() > o.data.size()) return false;
auto s = data.size();
@ -155,11 +155,11 @@ struct large_int : totally_ordered<large_int<Allocator>, large_int<Allocator>>,
}
bool operator==(const large_int& o) const noexcept {
BOOST_ASSERT(data.size() > 0u);
BOOST_ASSERT(o.data.size() > 0u);
assert(data.size() > 0u);
assert(o.data.size() > 0u);
// no leading zeros allowed
BOOST_ASSERT(data.size() == 1 || data.back() > 0u);
BOOST_ASSERT(o.data.size() == 1 || o.data.back() > 0u);
assert(data.size() == 1 || data.back() > 0u);
assert(o.data.size() == 1 || o.data.back() > 0u);
if (data.size() != o.data.size()) return false;
return std::equal(data.begin(), data.end(), o.data.begin());
}
@ -167,22 +167,22 @@ struct large_int : totally_ordered<large_int<Allocator>, large_int<Allocator>>,
template <class U>
std::enable_if_t<std::is_integral<U>::value, bool> operator<(const U& o) const
noexcept {
BOOST_ASSERT(data.size() > 0u);
assert(data.size() > 0u);
return data.size() == 1 && safe_less()(data[0], o);
}
template <class U>
std::enable_if_t<std::is_integral<U>::value, bool> operator>(const U& o) const
noexcept {
BOOST_ASSERT(data.size() > 0u);
BOOST_ASSERT(data.size() == 1 || data.back() > 0u); // no leading zeros allowed
assert(data.size() > 0u);
assert(data.size() == 1 || data.back() > 0u); // no leading zeros allowed
return data.size() > 1 || safe_less()(o, data[0]);
}
template <class U>
std::enable_if_t<std::is_integral<U>::value, bool> operator==(const U& o) const
noexcept {
BOOST_ASSERT(data.size() > 0u);
assert(data.size() > 0u);
return data.size() == 1 && safe_equal()(data[0], o);
}
@ -208,7 +208,7 @@ struct large_int : totally_ordered<large_int<Allocator>, large_int<Allocator>>,
}
static void add_remainder(std::uint64_t& d, const std::uint64_t o) noexcept {
BOOST_ASSERT(d > 0u);
assert(d > 0u);
// in decimal system it would look like this:
// 8 + 8 = 6 = 8 - (9 - 8) - 1
// 9 + 1 = 0 = 9 - (9 - 1) - 1

View File

@ -7,14 +7,13 @@
#ifndef BOOST_HISTOGRAM_DETAIL_LINEARIZE_HPP
#define BOOST_HISTOGRAM_DETAIL_LINEARIZE_HPP
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/histogram/axis/option.hpp>
#include <boost/histogram/axis/traits.hpp>
#include <boost/histogram/axis/variant.hpp>
#include <boost/histogram/detail/optional_index.hpp>
#include <boost/histogram/fwd.hpp>
#include <boost/histogram/multi_index.hpp>
#include <cassert>
namespace boost {
namespace histogram {
@ -26,20 +25,20 @@ std::size_t linearize(Opts, Index& out, const std::size_t stride,
const axis::index_type size, const axis::index_type idx) {
constexpr bool u = Opts::test(axis::option::underflow);
constexpr bool o = Opts::test(axis::option::overflow);
#ifdef BOOST_NO_CXX17_IF_CONSTEXPR
if
#else
if constexpr
#endif
(std::is_same<Index, std::size_t>::value || (u && o)) {
BOOST_ASSERT(idx >= (u ? -1 : 0));
BOOST_ASSERT(idx < (o ? size + 1 : size));
BOOST_ASSERT(idx >= 0 || static_cast<std::size_t>(-idx * stride) <= out);
// must be non-const to avoid if constexpr warning from msvc
bool fast_track = std::is_same<Index, std::size_t>::value || (u && o);
if (fast_track) {
assert(idx >= (u ? -1 : 0));
assert(idx < (o ? size + 1 : size));
assert(idx >= 0 || static_cast<std::size_t>(-idx * stride) <= out);
out += idx * stride;
} else {
BOOST_ASSERT(idx >= -1);
BOOST_ASSERT(idx < size + 1);
if ((u || idx >= 0) && (o || idx < size))
assert(idx >= -1);
assert(idx < size + 1);
// must be non-const to avoid if constexpr warning from msvc
bool is_valid = (u || idx >= 0) && (o || idx < size);
if (is_valid)
out += idx * stride;
else
out = invalid_index;
@ -65,7 +64,7 @@ std::size_t linearize_growth(Index& out, axis::index_type& shift,
constexpr bool u = axis::traits::get_options<Axis>::test(axis::option::underflow);
if (u) ++idx;
if (std::is_same<Index, std::size_t>::value) {
BOOST_ASSERT(idx < axis::traits::extent(a));
assert(idx < axis::traits::extent(a));
out += idx * stride;
} else {
if (0 <= idx && idx < axis::traits::extent(a))
@ -94,8 +93,7 @@ std::size_t linearize_index(optional_index& out, const std::size_t stride, const
template <class A, std::size_t N>
optional_index linearize_indices(const A& axes, const multi_index<N>& indices) noexcept {
BOOST_ASSERT_MSG(axes_rank(axes) == detail::size(indices),
"axes and indices must have equal lengths");
assert(axes_rank(axes) == detail::size(indices));
optional_index idx{0}; // offset not used by linearize_index
auto stride = static_cast<std::size_t>(1);

View File

@ -7,7 +7,7 @@
#ifndef BOOST_HISTOGRAM_DETAIL_OPTIONAL_INDEX_HPP
#define BOOST_HISTOGRAM_DETAIL_OPTIONAL_INDEX_HPP
#include <boost/assert.hpp>
#include <cassert>
#include <cstdint>
namespace boost {
@ -26,7 +26,7 @@ struct optional_index {
}
optional_index& operator+=(std::intptr_t x) noexcept {
BOOST_ASSERT(x >= 0 || static_cast<std::size_t>(-x) <= value);
assert(x >= 0 || static_cast<std::size_t>(-x) <= value);
if (value != invalid_index) { value += x; }
return *this;
}

View File

@ -7,10 +7,10 @@
#ifndef BOOST_HISTOGRAM_DETAIL_REDUCE_COMMAND_HPP
#define BOOST_HISTOGRAM_DETAIL_REDUCE_COMMAND_HPP
#include <boost/assert.hpp>
#include <boost/histogram/detail/span.hpp>
#include <boost/histogram/fwd.hpp>
#include <boost/throw_exception.hpp>
#include <cassert>
#include <stdexcept>
#include <string>
@ -46,7 +46,7 @@ inline void normalize_reduce_commands(span<reduce_command> out,
span<const reduce_command> in) {
unsigned iaxis = 0;
for (const auto& o_in : in) {
BOOST_ASSERT(o_in.merge > 0);
assert(o_in.merge > 0);
if (o_in.iaxis != reduce_command::unset && o_in.iaxis >= out.size())
BOOST_THROW_EXCEPTION(std::invalid_argument("invalid axis index"));
auto& o_out = out.begin()[o_in.iaxis == reduce_command::unset ? iaxis : o_in.iaxis];

View File

@ -35,8 +35,8 @@ using std::span;
// to be replaced by boost::span
#include <array>
#include <boost/assert.hpp>
#include <boost/histogram/detail/nonmember_container_access.hpp>
#include <cassert>
#include <initializer_list>
#include <iterator>
#include <type_traits>
@ -57,10 +57,14 @@ public:
constexpr std::size_t size() const noexcept { return N; }
protected:
constexpr span_base(T* b, std::size_t s) noexcept : begin_(b) { BOOST_ASSERT(N == s); }
constexpr span_base(T* b, std::size_t s) noexcept : begin_(b) {
(void)s;
assert(N == s);
}
constexpr void set(T* b, std::size_t s) noexcept {
(void)s;
begin_ = b;
BOOST_ASSERT(N == s);
assert(N == s);
}
private:
@ -112,8 +116,8 @@ public:
constexpr span(pointer first, pointer last)
: span(first, static_cast<std::size_t>(last - first)) {
BOOST_ASSERT(extent == dynamic_extent ||
static_cast<difference_type>(extent) == (last - first));
assert(extent == dynamic_extent ||
static_cast<difference_type>(extent) == (last - first));
}
constexpr span(pointer ptr, index_type count) : base(ptr, count) {}
@ -185,23 +189,23 @@ public:
template <std::size_t Count>
constexpr span<element_type, Count> first() const {
BOOST_ASSERT(Count <= base::size());
assert(Count <= base::size());
return span<element_type, Count>(base::data(), Count);
}
constexpr span<element_type, dynamic_extent> first(std::size_t count) const {
BOOST_ASSERT(count <= base::size());
assert(count <= base::size());
return span<element_type, dynamic_extent>(base::data(), count);
}
template <std::size_t Count>
constexpr span<element_type, Count> last() const {
BOOST_ASSERT(Count <= base::size());
assert(Count <= base::size());
return span<element_type, Count>(base::data() + base::size() - Count, Count);
}
constexpr span<element_type, dynamic_extent> last(std::size_t count) const {
BOOST_ASSERT(count <= base::size());
assert(count <= base::size());
return span<element_type, dynamic_extent>(base::data() + base::size() - count, count);
}
@ -211,21 +215,21 @@ public:
? Count
: (extent != dynamic_extent ? extent - Offset : dynamic_extent))>
subspan() const {
BOOST_ASSERT(Offset <= base::size());
assert(Offset <= base::size());
constexpr std::size_t E =
(Count != dynamic_extent
? Count
: (extent != dynamic_extent ? extent - Offset : dynamic_extent));
BOOST_ASSERT(E == dynamic_extent || E <= base::size());
assert(E == dynamic_extent || E <= base::size());
return span<element_type, E>(base::data() + Offset,
Count == dynamic_extent ? base::size() - Offset : Count);
}
constexpr span<element_type, dynamic_extent> subspan(
std::size_t offset, std::size_t count = dynamic_extent) const {
BOOST_ASSERT(offset <= base::size());
assert(offset <= base::size());
const std::size_t s = count == dynamic_extent ? base::size() - offset : count;
BOOST_ASSERT(s <= base::size());
assert(s <= base::size());
return span<element_type, dynamic_extent>(base::data() + offset, s);
}
};

View File

@ -33,9 +33,7 @@ public:
sub_array() = default;
explicit sub_array(std::size_t s) noexcept : size_(s) {
BOOST_ASSERT_MSG(size_ <= N, "requested size exceeds size of static buffer");
}
explicit sub_array(std::size_t s) noexcept : size_(s) { assert(size_ <= N); }
sub_array(std::size_t s, const T& value) noexcept(
std::is_nothrow_assignable<T, const_reference>::value)

View File

@ -7,38 +7,50 @@
#ifndef BOOST_HISTOGRAM_DETAIL_TRY_CAST_HPP
#define BOOST_HISTOGRAM_DETAIL_TRY_CAST_HPP
#include <boost/config.hpp>
#include <boost/core/demangle.hpp>
#include <boost/histogram/detail/type_name.hpp>
#include <boost/mp11/integral.hpp>
#include <boost/config.hpp> // BOOST_NORETURN
#include <boost/throw_exception.hpp>
#include <stdexcept>
#include <string>
#include <type_traits>
namespace boost {
namespace histogram {
namespace detail {
template <class T, class E, class U>
BOOST_NORETURN T try_cast_impl(mp11::mp_int<0>, U&&) {
BOOST_THROW_EXCEPTION(E("cannot cast " + type_name<T>() + " to " + type_name<U>()));
template <class T, class U>
constexpr T* ptr_cast(U*) noexcept {
return nullptr;
}
template <class T>
constexpr T* ptr_cast(T* p) noexcept {
return p;
}
template <class T>
constexpr const T* ptr_cast(const T* p) noexcept {
return p;
}
template <class T, class E, class U>
T try_cast_impl(mp11::mp_int<1>, U&& u) noexcept {
return static_cast<T>(u);
BOOST_NORETURN T try_cast_impl(std::false_type, std::false_type, U&&) {
BOOST_THROW_EXCEPTION(E("type cast error"));
}
// converting cast
template <class T, class E, class U>
decltype(auto) try_cast_impl(mp11::mp_int<2>, U&& u) noexcept {
return std::forward<U>(u);
T try_cast_impl(std::false_type, std::true_type, U&& u) noexcept {
return static_cast<T>(u); // cast to avoid warnings
}
// pass-through cast
template <class T, class E>
T&& try_cast_impl(std::true_type, std::true_type, T&& t) noexcept {
return std::forward<T>(t);
}
// cast fails at runtime with exception E instead of compile-time, T must be a value
template <class T, class E, class U>
decltype(auto) try_cast(U&& u) noexcept(std::is_convertible<U, T>::value) {
return try_cast_impl<T, E>(mp11::mp_int<(std::is_convertible<U, T>::value +
std::is_same<T, std::decay_t<U>>::value)>{},
T try_cast(U&& u) noexcept(std::is_convertible<U, T>::value) {
return try_cast_impl<T, E>(std::is_same<U, T>{}, std::is_convertible<U, T>{},
std::forward<U>(u));
}

View File

@ -140,14 +140,14 @@ public:
/// This version is more efficient than the one accepting a run-time number.
template <unsigned N = 0>
decltype(auto) axis(std::integral_constant<unsigned, N> = {}) const {
BOOST_ASSERT_MSG(N < rank(), "index out of range");
assert(N < rank());
return detail::axis_get<N>(axes_);
}
/// Get N-th axis with run-time number.
/// Prefer the version that accepts a compile-time number, if you can use it.
decltype(auto) axis(unsigned i) const {
BOOST_ASSERT_MSG(i < rank(), "index out of range");
assert(i < rank());
return detail::axis_get(axes_, i);
}
@ -371,7 +371,7 @@ public:
const auto idx = detail::linearize_indices(axes_, is);
if (!is_valid(idx))
BOOST_THROW_EXCEPTION(std::out_of_range("at least one index out of bounds"));
BOOST_ASSERT(idx < storage_.size());
assert(idx < storage_.size());
return storage_[idx];
}
@ -383,7 +383,7 @@ public:
const auto idx = detail::linearize_indices(axes_, is);
if (!is_valid(idx))
BOOST_THROW_EXCEPTION(std::out_of_range("at least one index out of bounds"));
BOOST_ASSERT(idx < storage_.size());
assert(idx < storage_.size());
return storage_[idx];
}

View File

@ -8,7 +8,7 @@
#define BOOST_HISTOGRAM_INDEXED_HPP
#include <array>
#include <boost/config.hpp>
#include <boost/config.hpp> // BOOST_ATTRIBUTE_NODISCARD
#include <boost/histogram/axis/traits.hpp>
#include <boost/histogram/detail/axes.hpp>
#include <boost/histogram/detail/iterator_adaptor.hpp>
@ -132,7 +132,7 @@ public:
/// Access indices as an iterable range.
index_view indices() const noexcept {
BOOST_ASSERT(iter_.indices_.hist_);
assert(iter_.indices_.hist_);
return {iter_.indices_.begin(), iter_.indices_.end()};
}
@ -140,7 +140,7 @@ public:
/// @tparam N axis dimension.
template <unsigned N = 0>
decltype(auto) bin(std::integral_constant<unsigned, N> = {}) const {
BOOST_ASSERT(iter_.indices_.hist_);
assert(iter_.indices_.hist_);
return iter_.indices_.hist_->axis(std::integral_constant<unsigned, N>())
.bin(index(N));
}
@ -148,7 +148,7 @@ public:
/// Access current bin.
/// @param d axis dimension.
decltype(auto) bin(unsigned d) const {
BOOST_ASSERT(iter_.indices_.hist_);
assert(iter_.indices_.hist_);
return iter_.indices_.hist_->axis(d).bin(index(d));
}
@ -158,7 +158,7 @@ public:
without bin widths, like axis::category, are treated as having unit bin with.
*/
double density() const {
BOOST_ASSERT(iter_.indices_.hist_);
assert(iter_.indices_.hist_);
double x = 1;
unsigned d = 0;
iter_.indices_.hist_->for_each_axis([&](const auto& a) {
@ -239,7 +239,7 @@ public:
pointer operator->() noexcept { return pointer_proxy{operator*()}; }
iterator& operator++() {
BOOST_ASSERT(iter_ < indices_.hist_->end());
assert(iter_ < indices_.hist_->end());
const auto cbeg = indices_.begin();
auto c = cbeg;
++iter_;

View File

@ -8,7 +8,6 @@
#ifndef BOOST_HISTOGRAM_OSTREAM_HPP
#define BOOST_HISTOGRAM_OSTREAM_HPP
#include <boost/config/workaround.hpp>
#include <boost/histogram/accumulators/ostream.hpp>
#include <boost/histogram/axis/ostream.hpp>
#include <boost/histogram/detail/counting_streambuf.hpp>
@ -50,15 +49,15 @@ public:
if (collect_) {
if (static_cast<unsigned>(iter_ - base_t::begin()) == size_) {
++size_;
BOOST_ASSERT(size_ <= N);
BOOST_ASSERT(iter_ != end());
assert(size_ <= N);
assert(iter_ != end());
*iter_ = 0;
}
count_ = 0;
os_ << t;
*iter_ = std::max(*iter_, static_cast<int>(count_));
} else {
BOOST_ASSERT(iter_ != end());
assert(iter_ != end());
os_ << std::setw(*iter_) << t;
}
++iter_;
@ -88,7 +87,7 @@ public:
auto cend() const { return base_t::cbegin() + size_; }
void complete() {
BOOST_ASSERT(collect_); // only call this once
assert(collect_); // only call this once
collect_ = false;
os_.rdbuf(orig_);
}
@ -192,9 +191,9 @@ void ostream_head(OStream& os, const Axis& ax, int index, double val) {
ax);
}
// cannot display generalized histograms yet
// cannot display generalized histograms yet; line not reachable by coverage tests
template <class OStream, class Histogram>
void ascii_plot(OStream&, const Histogram&, int, std::false_type) {}
void ascii_plot(OStream&, const Histogram&, int, std::false_type) {} // LCOV_EXCL_LINE
template <class OStream, class Histogram>
void ascii_plot(OStream& os, const Histogram& h, int w_total, std::true_type) {
@ -301,13 +300,9 @@ std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>&
using value_type = typename histogram<A, S>::value_type;
#if BOOST_WORKAROUND(BOOST_MSVC, >= 0)
#pragma warning(disable : 4127) // warning to use `if constexpr`
#endif
if (std::is_convertible<value_type, double>::value && h.rank() == 1) {
#if BOOST_WORKAROUND(BOOST_MSVC, >= 0)
#pragma warning(default : 4127)
#endif
// must be non-const to avoid a msvc warning about possible use of if constexpr
bool show_ascii = std::is_convertible<value_type, double>::value && h.rank() == 1;
if (show_ascii) {
detail::ostream(os, h, false);
detail::ascii_plot(os, h, w, std::is_convertible<value_type, double>{});
} else {

View File

@ -9,8 +9,6 @@
#define BOOST_HISTOGRAM_UNLIMTED_STORAGE_HPP
#include <algorithm>
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/core/alloc_construct.hpp>
#include <boost/core/exchange.hpp>
#include <boost/core/nvp.hpp>
@ -23,6 +21,7 @@
#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/list.hpp>
#include <boost/mp11/utility.hpp>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <functional>
@ -84,7 +83,7 @@ void* buffer_create(Allocator& a, std::size_t n) {
template <class Allocator, class Iterator>
auto buffer_create(Allocator& a, std::size_t n, Iterator iter) {
BOOST_ASSERT(n > 0u);
assert(n > 0u);
auto ptr = a.allocate(n); // may throw
static_assert(std::is_trivially_copyable<decltype(ptr)>::value,
"ptr must be trivially copyable");
@ -105,8 +104,8 @@ auto buffer_create(Allocator& a, std::size_t n, Iterator iter) {
template <class Allocator>
void buffer_destroy(Allocator& a, typename std::allocator_traits<Allocator>::pointer p,
std::size_t n) {
BOOST_ASSERT(p);
BOOST_ASSERT(n > 0u);
assert(p);
assert(n > 0u);
boost::alloc_destroy_n(a, p, n);
a.deallocate(p, n);
}
@ -203,7 +202,7 @@ public:
~buffer_type() noexcept { destroy(); }
void destroy() noexcept {
BOOST_ASSERT((ptr == nullptr) == (size == 0));
assert((ptr == nullptr) == (size == 0));
if (ptr == nullptr) return;
visit([this](auto* p) {
using T = std::decay_t<decltype(*p)>;
@ -263,7 +262,7 @@ public:
: detail::partially_ordered<const_reference, const_reference, void> {
public:
const_reference(buffer_type& b, std::size_t i) noexcept : bref_(b), idx_(i) {
BOOST_ASSERT(idx_ < bref_.size);
assert(idx_ < bref_.size);
}
const_reference(const const_reference&) noexcept = default;
@ -441,15 +440,11 @@ public:
auto s_begin = begin(s);
auto s_end = end(s);
using V = typename std::iterator_traits<decltype(begin(s))>::value_type;
constexpr auto ti = buffer_type::template type_index<V>();
constexpr auto nt = mp11::mp_size<typename buffer_type::types>::value;
// must be non-const to avoid msvc warning about if constexpr
auto ti = buffer_type::template type_index<V>();
auto nt = mp11::mp_size<typename buffer_type::types>::value;
const std::size_t size = static_cast<std::size_t>(std::distance(s_begin, s_end));
#ifdef BOOST_NO_CXX17_IF_CONSTEXPR
if
#else
if constexpr
#endif
(ti < nt)
if (ti < nt)
buffer_.template make<V>(size, s_begin);
else
buffer_.template make<double>(size, s_begin);
@ -513,7 +508,7 @@ public:
ar& make_nvp("type", tmp.type);
ar& make_nvp("size", size);
tmp.visit([this, size](auto* tp) {
BOOST_ASSERT(tp == nullptr);
assert(tp == nullptr);
using T = std::decay_t<decltype(*tp)>;
buffer_.template make<T>(size);
});
@ -531,7 +526,7 @@ private:
struct incrementor {
template <class T>
void operator()(T* tp, buffer_type& b, std::size_t i) {
BOOST_ASSERT(tp && i < b.size);
assert(tp && i < b.size);
if (!detail::safe_increment(tp[i])) {
using U = detail::next_type<typename buffer_type::types, T>;
b.template make<U>(b.size, tp);

View File

@ -48,7 +48,7 @@ struct unsafe_access {
*/
template <class Histogram, unsigned I = 0>
static decltype(auto) axis(Histogram& hist, std::integral_constant<unsigned, I> = {}) {
BOOST_ASSERT_MSG(I < hist.rank(), "index out of range");
assert(I < hist.rank());
return detail::axis_get<I>(hist.axes_);
}
@ -59,7 +59,7 @@ struct unsafe_access {
*/
template <class Histogram>
static decltype(auto) axis(Histogram& hist, unsigned i) {
BOOST_ASSERT_MSG(i < hist.rank(), "index out of range");
assert(i < hist.rank());
return detail::axis_get(hist.axes_, i);
}

View File

@ -4,18 +4,19 @@
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/assert.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/histogram/accumulators.hpp>
#include <boost/histogram/serialization.hpp>
#include <boost/histogram/weight.hpp>
#include <cassert>
#include "throw_exception.hpp"
#include "utility_serialization.hpp"
using namespace boost::histogram;
int main(int argc, char** argv) {
BOOST_ASSERT(argc == 2);
(void)argc;
assert(argc == 2);
// mean v0
{

View File

@ -4,7 +4,6 @@
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/core/ignore_unused.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <boost/histogram/axis/category.hpp>
@ -30,7 +29,7 @@ int main() {
// bad ctor
{
int x[2];
boost::ignore_unused(x);
(void)x;
BOOST_TEST_THROWS(axis::category<int>(x + 1, x), std::invalid_argument);
}

View File

@ -6,7 +6,7 @@
// This test is inspired by the corresponding boost/beast test of detail_variant.
#include <boost/assert.hpp>
#include <cassert>
#include <boost/core/lightweight_test.hpp>
#include <boost/histogram/axis/integer.hpp>
#include <boost/histogram/axis/ostream.hpp>
@ -20,7 +20,7 @@
using namespace boost::histogram::axis;
int main(int argc, char** argv) {
BOOST_ASSERT(argc == 2);
assert(argc == 2);
const auto filename = join(argv[1], "axis_variant_serialization_test.xml");

View File

@ -5,7 +5,6 @@
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <algorithm>
#include <boost/core/ignore_unused.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/histogram/axis.hpp>
#include <boost/histogram/axis/ostream.hpp>
@ -69,7 +68,7 @@ int main() {
h.fill(inputs); // should not crash
auto bad = std::vector<I>(BOOST_HISTOGRAM_DETAIL_AXES_LIMIT + 1, I(0, 1));
boost::ignore_unused(bad);
(void)bad;
BOOST_TEST_THROWS((void)make_histogram(bad), std::invalid_argument);
}

View File

@ -6,7 +6,6 @@
#include <array>
#include <boost/config.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/histogram/accumulators.hpp>
#include <boost/histogram/accumulators/ostream.hpp>
@ -14,12 +13,12 @@
#include <boost/histogram/axis/category.hpp>
#include <boost/histogram/axis/integer.hpp>
#include <boost/histogram/axis/ostream.hpp>
#include <boost/variant2/variant.hpp>
#include <boost/histogram/histogram.hpp>
#include <boost/histogram/literals.hpp>
#include <boost/histogram/make_histogram.hpp>
#include <boost/histogram/ostream.hpp>
#include <boost/histogram/storage_adaptor.hpp>
#include <boost/variant2/variant.hpp>
#include <random>
#include <sstream>
#include <stdexcept>
@ -105,11 +104,11 @@ void run_tests(const std::vector<int>& x, const std::vector<int>& y,
auto h = make(Tag(), in{1, 3});
int bad1[2][4];
boost::ignore_unused(bad1);
(void)bad1;
BOOST_TEST_THROWS(h.fill(bad1), std::invalid_argument);
std::vector<std::array<int, 4>> bad2;
boost::ignore_unused(bad2);
(void)bad2;
BOOST_TEST_THROWS(h.fill(bad2), std::invalid_argument);
}
@ -148,7 +147,7 @@ void run_tests(const std::vector<int>& x, const std::vector<int>& y,
BOOST_TEST_EQ(h, h2);
auto w2 = {1};
boost::ignore_unused(w2);
(void)w2;
BOOST_TEST_THROWS(h2.fill(x, weight(w2)), std::invalid_argument);
}
@ -168,7 +167,7 @@ void run_tests(const std::vector<int>& x, const std::vector<int>& y,
// not rectangular
std::array<std::vector<int>, 2> bad = {{std::vector<int>(1), std::vector<int>(2)}};
boost::ignore_unused(bad);
(void)bad;
BOOST_TEST_THROWS(h2.fill(bad), std::invalid_argument);
}
@ -285,7 +284,7 @@ void run_tests(const std::vector<int>& x, const std::vector<int>& y,
BOOST_TEST_EQ(h, h2);
const auto bad = {V(std::vector<std::string>(1, "foo")), V(std::vector<int>{1, 2})};
boost::ignore_unused(bad);
(void)bad;
BOOST_TEST_THROWS(h.fill(bad), std::invalid_argument);
}

View File

@ -4,7 +4,7 @@
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/assert.hpp>
#include <cassert>
#include <boost/core/lightweight_test.hpp>
#include <boost/histogram/axis.hpp>
#include <boost/histogram/axis/ostream.hpp>
@ -43,7 +43,7 @@ void run_tests(const std::string& filename) {
}
int main(int argc, char** argv) {
BOOST_ASSERT(argc == 2);
assert(argc == 2);
run_tests<static_tag>(join(argv[1], "histogram_serialization_test_static.xml"));
run_tests<dynamic_tag>(join(argv[1], "histogram_serialization_test_dynamic.xml"));
return boost::report_errors();

View File

@ -444,10 +444,10 @@ void run_tests() {
BOOST_TEST_EQ(h.at(j11), 1);
BOOST_TEST_EQ(h[j11], 1);
int j111[] = {1, 1, 1};
boost::ignore_unused(j111);
(void)j111;
BOOST_TEST_THROWS((void)h.at(j111), std::invalid_argument);
int j13[] = {1, 3};
boost::ignore_unused(j13);
(void)j13;
BOOST_TEST_THROWS((void)h.at(j13), std::out_of_range);
// tuple with weight

View File

@ -5,7 +5,7 @@
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <array>
#include <boost/assert.hpp>
#include <cassert>
#include <boost/core/lightweight_test.hpp>
#include <boost/histogram/accumulators/thread_safe.hpp>
#include <boost/histogram/serialization.hpp>
@ -32,7 +32,7 @@ void test_serialization(const std::string& filename) {
}
int main(int argc, char** argv) {
BOOST_ASSERT(argc == 2);
assert(argc == 2);
test_serialization<std::vector<int>>(
join(argv[1], "storage_adaptor_serialization_test_vector_int.xml"));

View File

@ -6,7 +6,7 @@
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/assert.hpp>
#include <cassert>
#include <boost/core/lightweight_test.hpp>
#include <boost/histogram/serialization.hpp>
#include <boost/histogram/unlimited_storage.hpp>
@ -43,7 +43,7 @@ void run_test(const std::string& filename) {
}
int main(int argc, char** argv) {
BOOST_ASSERT(argc == 2);
assert(argc == 2);
run_test<uint8_t>(join(argv[1], "unlimited_storage_serialization_test_u8.xml"));
run_test<uint16_t>(join(argv[1], "unlimited_storage_serialization_test_u16.xml"));

View File

@ -5,11 +5,11 @@
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <algorithm>
#include <boost/config.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/typeinfo.hpp>
#include <boost/histogram/detail/type_name.hpp>
#include <boost/throw_exception.hpp>
#include <initializer_list>
#include <iostream>
#include <unordered_map>
#include <utility>
@ -32,7 +32,8 @@ struct tracing_allocator_db : std::pair<int, int> {
template <class... Ts>
void log(Ts&&... ts) {
if (!tracing) return;
log_impl(std::forward<Ts>(ts)...);
// fold trick
(void)std::initializer_list<int>{(std::cerr << ts, 0)...};
std::cerr << std::endl;
}
@ -41,14 +42,6 @@ struct tracing_allocator_db : std::pair<int, int> {
private:
using map_t = std::unordered_map<const boost::core::typeinfo*, std::pair<int, int>>;
map_t map_;
BOOST_ATTRIBUTE_UNUSED inline void log_impl() {}
template <class T, class... Ts>
void log_impl(T&& t, Ts&&... ts) {
std::cerr << t;
log_impl(std::forward<Ts>(ts)...);
}
};
template <class T>

View File

@ -9,9 +9,9 @@
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/config.hpp> // BOOST_WINDOWS
#include <boost/core/nvp.hpp>
#include <cassert>
#include <fstream>
#include <iostream>
#include <string>
@ -31,13 +31,13 @@ std::string join(const char* a, const char* b) {
template <class T>
void load_xml(const std::string& filename, T& t) {
std::ifstream ifs(filename);
BOOST_ASSERT(ifs.is_open());
assert(ifs.is_open());
// manually skip XML comments at the beginning of the stream, because of
// https://github.com/boostorg/serialization/issues/169
char line[128];
do {
ifs.getline(line, 128);
BOOST_ASSERT(std::strlen(line) < 127);
assert(std::strlen(line) < 127);
} while (!ifs.fail() && !ifs.eof() && std::strstr(line, "-->") == nullptr);
boost::archive::xml_iarchive ia(ifs);
ia >> boost::make_nvp("item", t);