Skip to content

Commit

Permalink
Avoid std::equal volatile comparisons for libc++ (martinmoene#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 0518c9e
Showing 1 changed file with 8 additions and 1 deletion.
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 0518c9e

Please sign in to comment.