Skip to content

Commit fa27e36

Browse files
author
MarcoFalke
committed
test: Fix broken span_tests
* The comment is wrong claiming that void* was returned when void was returned in reality. * The namespace is missing a name, leading to compile errors that are suppressed with non-standard pragmas, and leading to compile errors in future commits. Instead of using more non-standard suppressions, just add the missing name. * The SpanableYes/No types are missing begin/end iterators, which will be needed when using std::span.
1 parent fadf02e commit fa27e36

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/test/span_tests.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <set>
1010
#include <vector>
1111

12-
namespace {
12+
namespace spannable {
1313
struct Ignore
1414
{
1515
template<typename T> Ignore(T&&) {}
@@ -24,25 +24,21 @@ bool Spannable(Ignore)
2424
return false;
2525
}
2626

27-
#if defined(__clang__)
28-
# pragma clang diagnostic push
29-
# pragma clang diagnostic ignored "-Wunneeded-member-function"
30-
# pragma clang diagnostic ignored "-Wunused-member-function"
31-
#endif
3227
struct SpannableYes
3328
{
3429
int* data();
30+
int* begin();
31+
int* end();
3532
size_t size();
3633
};
3734
struct SpannableNo
3835
{
39-
void* data();
36+
void data();
4037
size_t size();
4138
};
42-
#if defined(__clang__)
43-
# pragma clang diagnostic pop
44-
#endif
45-
} // namespace
39+
} // namespace spannable
40+
41+
using namespace spannable;
4642

4743
BOOST_AUTO_TEST_SUITE(span_tests)
4844

@@ -54,7 +50,7 @@ BOOST_AUTO_TEST_SUITE(span_tests)
5450
//
5551
// Previously there was a bug where writing a SFINAE check for vector<bool> was
5652
// not possible, because in libstdc++ vector<bool> has a data() member
57-
// returning void*, and the Span template guide ignored the data() return value,
53+
// returning void, and the Span template guide ignored the data() return value,
5854
// so the template substitution would succeed, but the constructor would fail,
5955
// resulting in a fatal compile error, rather than a SFINAE error that could be
6056
// handled.

0 commit comments

Comments
 (0)