Skip to content

Commit

Permalink
Avoid std::equal volatile comparisons for libc++ (#44)
Browse files Browse the repository at this point in the history
libc++ doesn't allow us to perform std::equal on volatile and
non-volatile types. We can work around this by iterating over the span
and manually comparing.
  • Loading branch information
wkennington authored and martinmoene committed Dec 15, 2019
1 parent c8bb39f commit 7936b2d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ addons:
- llvm-toolchain-trusty-4.0
- llvm-toolchain-trusty-5.0
- llvm-toolchain-trusty-6.0
- llvm-toolchain-trusty-8

matrix:
include:
Expand Down Expand Up @@ -132,6 +133,14 @@ matrix:
packages: ["clang-6.0", "g++-7", "python3-pip", "lcov"]
sources: *apt_sources

- os: linux
env: COMPILER=clang++-8 CXXFLAGS=-stdlib=libc++
compiler: clang
addons: &clang8
apt:
packages: ["clang-8", "g++-7", "python3-pip", "lcov", 'libc++-8-dev', 'libc++abi-8-dev']
sources: *apt_sources

- os: osx
osx_image: xcode7.3
compiler: clang
Expand Down
9 changes: 8 additions & 1 deletion test/span.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <ciso646>
#include "span-main.t.hpp"

#define DIMENSION_OF( a ) ( sizeof(a) / sizeof(0[a]) )
Expand Down Expand Up @@ -437,9 +438,15 @@ CASE( "span<>: Allows to copy-construct from another span of a compatible type"

span<const volatile int> x( v );
span<const volatile int> y( v );

#ifndef _LIBCPP_VERSION
EXPECT( std::equal( x.begin(), x.end(), arr ) );
EXPECT( std::equal( y.begin(), y.end(), arr ) );
#else
for(size_t i = 0; i < x.size(); ++i)
EXPECT(x[i] == arr[i]);
for(size_t i = 0; i < y.size(); ++i)
EXPECT(y[i] == arr[i]);
#endif
}

CASE( "span<>: Allows to copy-construct from a temporary span of the same type (C++11)" )
Expand Down

0 comments on commit 7936b2d

Please sign in to comment.