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 committed Dec 13, 2019
1 parent c8bb39f commit 72a20f2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ matrix:
packages: ["clang-6.0", "g++-7", "python3-pip", "lcov"]
sources: *apt_sources

- os: linux
env: COMPILER=clang++-6.0 CXXFLAGS=-stdlib=libc++
compiler: clang
addons: &clang6_0
apt:
packages: ["clang-6.0", "g++-7", "python3-pip", "lcov", 'libc++-6.0-dev', 'libc++abi-6.0-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 72a20f2

Please sign in to comment.