Skip to content

Commit 01ccd0e

Browse files
authored
Merge pull request #931 from CaseyCarter/shhhh
Silence MSVC warnings, fix reverse_view
2 parents 7f2eb04 + cd58046 commit 01ccd0e

20 files changed

+71
-75
lines changed

cmake/ranges_env.cmake

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,16 @@ else()
5050
message("[range-v3 warning]: unknown system ${CMAKE_SYSTEM_NAME} !")
5151
endif()
5252

53-
# Clang-CL will blow up in the standard library if compiling with less than
54-
# C++14, and MSVC doesn't support less than C++14 at all.
5553
if (RANGES_CXX_COMPILER_CLANGCL OR RANGES_CXX_COMPILER_MSVC)
56-
if (RANGES_CXX_STD EQUAL 11)
57-
set(CMAKE_CXX_STANDARD 14)
54+
# Clang-CL will blow up in the standard library if compiling with less than
55+
# C++14, and MSVC doesn't support less than C++14 at all.
56+
if (RANGES_CXX_STD LESS 14)
5857
set(RANGES_CXX_STD 14)
5958
endif()
59+
# MSVC is currently supported only in 17+ mode
60+
if (RANGES_CXX_COMPILER_MSVC AND RANGES_CXX_STD LESS 17)
61+
set(RANGES_CXX_STD 17)
62+
endif()
6063
target_compile_definitions(range-v3 INTERFACE _SILENCE_CXX17_TEMPORARY_BUFFER_DEPRECATION_WARNING)
6164
endif()
6265

include/range/v3/detail/config.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ namespace ranges
197197
#define RANGES_DIAGNOSTIC_IGNORE_RANGE_LOOP_ANALYSIS
198198
#define RANGES_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS RANGES_DIAGNOSTIC_IGNORE(4996)
199199
#define RANGES_DIAGNOSTIC_IGNORE_DEPRECATED_THIS_CAPTURE
200-
#define RANGES_DIAGNOSTIC_IGNORE_DIVIDE_BY_ZERO RANGES_DIAGNOSTIC_IGNORE(4723)
200+
// Ignores both "divide by zero" and "mod by zero":
201+
#define RANGES_DIAGNOSTIC_IGNORE_DIVIDE_BY_ZERO \
202+
RANGES_DIAGNOSTIC_IGNORE(4723) RANGES_DIAGNOSTIC_IGNORE(4724)
201203

202204
#define RANGES_CXX_VER _MSVC_LANG
203205

include/range/v3/range_fwd.hpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -601,15 +601,7 @@ namespace ranges
601601
struct repeat_fn;
602602
}
603603

604-
namespace detail
605-
{
606-
template<typename>
607-
std::false_type double_reverse(long);
608-
template<typename R, meta::if_<std::is_same<R, typename R::unreverse_me>>* = nullptr>
609-
std::true_type double_reverse(int);
610-
}
611-
612-
template<typename Rng, bool = decltype(detail::double_reverse<Rng>(42))::value>
604+
template<typename Rng>
613605
struct RANGES_EMPTY_BASES reverse_view;
614606

615607
namespace view

include/range/v3/view/reverse.hpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace ranges
3737
{
3838
/// \addtogroup group-views
3939
/// @{
40-
template<typename Rng, bool /* = decltype(detail::double_reverse<Rng>(42))::value */>
40+
template<typename Rng>
4141
struct RANGES_EMPTY_BASES reverse_view
4242
: view_interface<reverse_view<Rng>, range_cardinality<Rng>::value>
4343
, private detail::non_propagating_cache<
@@ -107,22 +107,21 @@ namespace ranges
107107
{
108108
return ranges::size(rng_);
109109
}
110-
111-
using unreverse_me = reverse_view;
112110
};
113111

114-
template<typename Rng_>
115-
struct reverse_view<Rng_, true>
116-
: identity_adaptor<decltype(std::declval<Rng_ &>().base())>
112+
#if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 5
113+
template<typename Rng>
114+
struct reverse_view<reverse_view<Rng>>
115+
: identity_adaptor<Rng>
117116
{
118-
using Rng = decltype(std::declval<Rng_ &>().base());
119117
CONCEPT_ASSERT(BidirectionalRange<Rng>());
120118

121119
reverse_view() = default;
122-
explicit constexpr reverse_view(Rng_ rng)
120+
explicit constexpr reverse_view(reverse_view<Rng> const &rng)
123121
: identity_adaptor<Rng>(rng.base())
124122
{}
125123
};
124+
#endif // !GCC4
126125

127126
namespace view
128127
{

test/algorithm/count.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ int main()
2424
using namespace ranges;
2525

2626
int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
27-
constexpr unsigned cia = size(ia);
27+
constexpr auto cia = size(ia);
2828

2929
CHECK(count(input_iterator<const int*>(ia),
3030
sentinel<const int*>(ia + cia), 2) == 3);
@@ -41,7 +41,7 @@ int main()
4141
sentinel<const int*>(ia)), 2) == 0);
4242

4343
S sa[] = {{0}, {1}, {2}, {2}, {0}, {1}, {2}, {3}};
44-
constexpr unsigned csa = size(ia);
44+
constexpr auto csa = size(ia);
4545

4646
CHECK(count(input_iterator<const S*>(sa),
4747
sentinel<const S*>(sa + csa), 2, &S::i) == 3);

test/algorithm/count_if.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int main()
3131
auto equals = [](int i){ return std::bind(equal_to{}, i, std::placeholders::_1); };
3232

3333
int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
34-
constexpr unsigned cia = size(ia);
34+
constexpr auto cia = size(ia);
3535

3636
CHECK(count_if(input_iterator<const int*>(ia),
3737
sentinel<const int*>(ia + cia), equals(2)) == 3);
@@ -48,7 +48,7 @@ int main()
4848
sentinel<const int*>(ia)), equals(2)) == 0);
4949

5050
S sa[] = {{0}, {1}, {2}, {2}, {0}, {1}, {2}, {3}};
51-
constexpr unsigned csa = size(ia);
51+
constexpr auto csa = size(ia);
5252

5353
CHECK(count_if(input_iterator<const S*>(sa),
5454
sentinel<const S*>(sa + csa), equals(2), &S::i) == 3);

test/algorithm/equal.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void test()
2828
{
2929
using namespace ranges;
3030
int ia[] = {0, 1, 2, 3, 4, 5};
31-
constexpr unsigned s = size(ia);
31+
constexpr auto s = size(ia);
3232
int ib[s] = {0, 1, 2, 5, 4, 5};
3333
CHECK(equal(input_iterator<const int*>(ia),
3434
sentinel<const int*>(ia+s),
@@ -78,7 +78,7 @@ void test_rng()
7878
{
7979
using namespace ranges;
8080
int ia[] = {0, 1, 2, 3, 4, 5};
81-
constexpr unsigned s = size(ia);
81+
constexpr auto s = size(ia);
8282
int ib[s] = {0, 1, 2, 5, 4, 5};
8383
CHECK(equal(make_iterator_range(input_iterator<const int*>(ia),
8484
sentinel<const int*>(ia+s)),
@@ -137,7 +137,7 @@ void test_pred()
137137
{
138138
using namespace ranges;
139139
int ia[] = {0, 1, 2, 3, 4, 5};
140-
constexpr unsigned s = size(ia);
140+
constexpr auto s = size(ia);
141141
int ib[s] = {0, 1, 2, 5, 4, 5};
142142
CHECK(equal(input_iterator<const int*>(ia),
143143
sentinel<const int*>(ia+s),
@@ -205,7 +205,7 @@ void test_rng_pred()
205205
{
206206
using namespace ranges;
207207
int ia[] = {0, 1, 2, 3, 4, 5};
208-
constexpr unsigned s = size(ia);
208+
constexpr auto s = size(ia);
209209
int ib[s] = {0, 1, 2, 5, 4, 5};
210210
CHECK(equal(make_iterator_range(input_iterator<const int*>(ia),
211211
sentinel<const int*>(ia+s)),

test/algorithm/find.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int main()
3535
using namespace ranges;
3636

3737
int ia[] = {0, 1, 2, 3, 4, 5};
38-
constexpr unsigned s = size(ia);
38+
constexpr auto s = size(ia);
3939
input_iterator<const int*> r = find(input_iterator<const int*>(ia),
4040
input_iterator<const int*>(ia+s), 3);
4141
CHECK(*r == 3);

test/algorithm/find_end.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test()
3131
using namespace ranges;
3232

3333
int ia[] = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 0, 1, 2, 3, 0, 1, 2, 0, 1, 0};
34-
constexpr unsigned sa = size(ia);
34+
constexpr auto sa = size(ia);
3535
int b[] = {0};
3636
int c[] = {0, 1};
3737
int d[] = {0, 1, 2};
@@ -92,7 +92,7 @@ test_pred()
9292
using namespace ranges;
9393

9494
int ia[] = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 0, 1, 2, 3, 0, 1, 2, 0, 1, 0};
95-
constexpr unsigned sa = size(ia);
95+
constexpr auto sa = size(ia);
9696
int b[] = {0};
9797
int c[] = {0, 1};
9898
int d[] = {0, 1, 2};
@@ -174,7 +174,7 @@ test_proj()
174174
using namespace ranges;
175175

176176
S ia[] = {{0}, {1}, {2}, {3}, {4}, {5}, {0}, {1}, {2}, {3}, {4}, {0}, {1}, {2}, {3}, {0}, {1}, {2}, {0}, {1}, {0}};
177-
constexpr unsigned sa = size(ia);
177+
constexpr auto sa = size(ia);
178178
int b[] = {0};
179179
int c[] = {0, 1};
180180
int d[] = {0, 1, 2};

test/algorithm/find_first_of.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ void test_iter()
3030
{
3131
using namespace ranges;
3232
int ia[] = {0, 1, 2, 3, 0, 1, 2, 3};
33-
static constexpr unsigned sa = size(ia);
33+
static constexpr auto sa = size(ia);
3434
int ib[] = {1, 3, 5, 7};
35-
static constexpr unsigned sb = size(ib);
35+
static constexpr auto sb = size(ib);
3636
CHECK(rng::find_first_of(input_iterator<const int*>(ia),
3737
sentinel<const int*>(ia + sa),
3838
forward_iterator<const int*>(ib),
@@ -60,9 +60,9 @@ void test_iter_pred()
6060
{
6161
using namespace ranges;
6262
int ia[] = {0, 1, 2, 3, 0, 1, 2, 3};
63-
static constexpr unsigned sa = size(ia);
63+
static constexpr auto sa = size(ia);
6464
int ib[] = {1, 3, 5, 7};
65-
static constexpr unsigned sb = size(ib);
65+
static constexpr auto sb = size(ib);
6666
CHECK(rng::find_first_of(input_iterator<const int*>(ia),
6767
sentinel<const int*>(ia + sa),
6868
forward_iterator<const int*>(ib),
@@ -94,9 +94,9 @@ void test_rng()
9494
{
9595
using namespace ranges;
9696
int ia[] = {0, 1, 2, 3, 0, 1, 2, 3};
97-
static constexpr unsigned sa = size(ia);
97+
static constexpr auto sa = size(ia);
9898
int ib[] = {1, 3, 5, 7};
99-
static constexpr unsigned sb = size(ib);
99+
static constexpr auto sb = size(ib);
100100
CHECK(rng::find_first_of(as_lvalue(make_iterator_range(input_iterator<const int*>(ia),
101101
input_iterator<const int*>(ia + sa))),
102102
make_iterator_range(forward_iterator<const int*>(ib),
@@ -144,9 +144,9 @@ void test_rng_pred()
144144
{
145145
using namespace ranges;
146146
int ia[] = {0, 1, 2, 3, 0, 1, 2, 3};
147-
static constexpr unsigned sa = size(ia);
147+
static constexpr auto sa = size(ia);
148148
int ib[] = {1, 3, 5, 7};
149-
static constexpr unsigned sb = size(ib);
149+
static constexpr auto sb = size(ib);
150150
CHECK(rng::find_first_of(as_lvalue(make_iterator_range(input_iterator<const int*>(ia),
151151
input_iterator<const int*>(ia + sa))),
152152
make_iterator_range(forward_iterator<const int*>(ib),
@@ -183,9 +183,9 @@ void test_rng_pred_proj()
183183
{
184184
using namespace ranges;
185185
S ia[] = {S{0}, S{1}, S{2}, S{3}, S{0}, S{1}, S{2}, S{3}};
186-
static constexpr unsigned sa = size(ia);
186+
static constexpr auto sa = size(ia);
187187
S ib[] = {S{1}, S{3}, S{5}, S{7}};
188-
static constexpr unsigned sb = size(ib);
188+
static constexpr auto sb = size(ib);
189189
CHECK(rng::find_first_of(as_lvalue(make_iterator_range(input_iterator<const S*>(ia),
190190
input_iterator<const S*>(ia + sa))),
191191
make_iterator_range(forward_iterator<const S*>(ib),

0 commit comments

Comments
 (0)