mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-09 23:04:07 +00:00
fix compile issues on clang with cxxstd=latest
added tests of clang with cxxstd=latest to detect issue
This commit is contained in:
parent
30899cb45d
commit
5a893c467c
@ -47,7 +47,7 @@ test_script:
|
||||
- sh:
|
||||
../../b2 $B2_OPTS cxxstd=14 exception-handling=off rtti=off test//minimal &&
|
||||
../../b2 $B2_OPTS toolset=gcc-9 cxxstd=latest examples test//all &&
|
||||
../../b2 $B2_OPTS toolset=clang cxxstd=14 variant=histogram_ubasan test//all
|
||||
../../b2 $B2_OPTS toolset=clang cxxstd=latest variant=histogram_ubasan test//all
|
||||
|
||||
on_failure:
|
||||
# Uncomment the following line to stop VM and enable interactive login
|
||||
|
33
.travis.yml
33
.travis.yml
@ -14,8 +14,11 @@ branches:
|
||||
- develop
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
include:
|
||||
- os: osx
|
||||
- name: osx and cmake
|
||||
os: osx
|
||||
language: cpp
|
||||
before_script:
|
||||
- mkdir build
|
||||
@ -24,6 +27,30 @@ matrix:
|
||||
script:
|
||||
ctest -j2
|
||||
|
||||
- name: osx and b2
|
||||
os: osx
|
||||
language: cpp
|
||||
before_script:
|
||||
# clone minimal set of Boost libraries
|
||||
- cd ..
|
||||
- git clone -b $TRAVIS_BRANCH --depth 5 https://github.com/boostorg/boost.git
|
||||
- cd boost
|
||||
- git submodule update --init --depth 5 tools/build tools/boostdep
|
||||
|
||||
# replace library with this version and install dependencies
|
||||
- rm -rf libs/histogram
|
||||
- mv $TRAVIS_BUILD_DIR libs/histogram
|
||||
- python tools/boostdep/depinst/depinst.py --git_args "--depth 5 --jobs 3" histogram
|
||||
|
||||
# prepare build
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
- cd libs/histogram
|
||||
- B2="../../b2 -q -j2 warnings-as-errors=on"
|
||||
script:
|
||||
$B2 cxxstd=latest exception-handling=off test//minimal &&
|
||||
$B2 cxxstd=latest test//all
|
||||
|
||||
- os: linux
|
||||
language: python
|
||||
python: "3.6"
|
||||
@ -55,7 +82,7 @@ matrix:
|
||||
$B2 toolset=gcc-5 cxxstd=14 examples test//all &&
|
||||
$B2 toolset=gcc-5 cxxstd=14 exception-handling=off rtti=off test//minimal &&
|
||||
$B2 toolset=gcc-8 cxxstd=latest coverage=on test//all &&
|
||||
GCOV=gcov-8 tools/cov.sh
|
||||
|
||||
GCOV=gcov-8 tools/cov.sh
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
@ -32,6 +32,8 @@ namespace boost {
|
||||
namespace histogram {
|
||||
namespace detail {
|
||||
|
||||
namespace dtl = ::boost::histogram::detail;
|
||||
|
||||
static constexpr std::size_t dynamic_extent = ~static_cast<std::size_t>(0);
|
||||
|
||||
template <class T, std::size_t N>
|
||||
@ -105,31 +107,30 @@ public:
|
||||
constexpr span(pointer ptr, index_type count) : base(ptr, count) {}
|
||||
|
||||
template <std::size_t N>
|
||||
constexpr span(element_type (&arr)[N]) noexcept : span(data(arr), N) {
|
||||
constexpr span(element_type (&arr)[N]) noexcept : span(dtl::data(arr), N) {
|
||||
static_assert(extent == dynamic_extent || extent == N, "static sizes do not match");
|
||||
}
|
||||
|
||||
template <std::size_t N,
|
||||
class = std::enable_if_t<(extent == dynamic_extent || extent == N)> >
|
||||
constexpr span(std::array<value_type, N>& arr) noexcept : span(data(arr), N) {}
|
||||
constexpr span(std::array<value_type, N>& arr) noexcept : span(dtl::data(arr), N) {}
|
||||
|
||||
template <std::size_t N,
|
||||
class = std::enable_if_t<(extent == dynamic_extent || extent == N)> >
|
||||
constexpr span(const std::array<value_type, N>& arr) noexcept : span(data(arr), N) {}
|
||||
constexpr span(const std::array<value_type, N>& arr) noexcept
|
||||
: span(dtl::data(arr), N) {}
|
||||
|
||||
template <
|
||||
class Container,
|
||||
class = std::enable_if_t<std::is_convertible<
|
||||
decltype(size(std::declval<Container>()), data(std::declval<Container>())),
|
||||
pointer>::value> >
|
||||
constexpr span(const Container& cont) : span(data(cont), size(cont)) {}
|
||||
template <class Container, class = std::enable_if_t<std::is_convertible<
|
||||
decltype(dtl::size(std::declval<Container>()),
|
||||
dtl::data(std::declval<Container>())),
|
||||
pointer>::value> >
|
||||
constexpr span(const Container& cont) : span(dtl::data(cont), dtl::size(cont)) {}
|
||||
|
||||
template <
|
||||
class Container,
|
||||
class = std::enable_if_t<std::is_convertible<
|
||||
decltype(size(std::declval<Container>()), data(std::declval<Container>())),
|
||||
pointer>::value> >
|
||||
constexpr span(Container& cont) : span(data(cont), size(cont)) {}
|
||||
template <class Container, class = std::enable_if_t<std::is_convertible<
|
||||
decltype(dtl::size(std::declval<Container>()),
|
||||
dtl::data(std::declval<Container>())),
|
||||
pointer>::value> >
|
||||
constexpr span(Container& cont) : span(dtl::data(cont), dtl::size(cont)) {}
|
||||
|
||||
template <class U, std::size_t N,
|
||||
class = std::enable_if_t<((extent == dynamic_extent || extent == N) &&
|
||||
@ -229,10 +230,10 @@ span<T> make_span(T* begin, std::size_t size) {
|
||||
return span<T>{begin, size};
|
||||
}
|
||||
|
||||
template <class Container, class = decltype(size(std::declval<Container>()),
|
||||
data(std::declval<Container>()))>
|
||||
template <class Container, class = decltype(dtl::size(std::declval<Container>()),
|
||||
dtl::data(std::declval<Container>()))>
|
||||
auto make_span(const Container& cont) {
|
||||
return make_span(data(cont), size(cont));
|
||||
return make_span(dtl::data(cont), dtl::size(cont));
|
||||
}
|
||||
|
||||
template <class T, std::size_t N>
|
||||
|
@ -4,6 +4,7 @@
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <array>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/histogram/accumulators.hpp>
|
||||
@ -92,11 +93,14 @@ void run_tests(const std::vector<int>& x, const std::vector<int>& y,
|
||||
|
||||
BOOST_TEST_EQ(h, h2);
|
||||
|
||||
BOOST_TEST_THROWS(h2.fill(std::array<std::vector<int>, 2>(
|
||||
{std::vector<int>(2), std::vector<int>(3)})),
|
||||
std::invalid_argument);
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
// wrong rank
|
||||
BOOST_TEST_THROWS(h.fill(x), std::invalid_argument);
|
||||
|
||||
// not rectangular
|
||||
std::array<std::vector<int>, 2> bad = {{std::vector<int>(2), std::vector<int>(3)}};
|
||||
BOOST_TEST_THROWS(h2.fill(bad), std::invalid_argument);
|
||||
#endif
|
||||
}
|
||||
|
||||
// 1D variant and weight
|
||||
|
Loading…
x
Reference in New Issue
Block a user