Skip to content

Commit 61cebfe

Browse files
authored
Removed workaround for old compilers and old C++ standards (#2902)
1 parent ff10a85 commit 61cebfe

11 files changed

Lines changed: 11 additions & 137 deletions

File tree

include/xtensor/containers/xfixed.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,7 @@ namespace xt
256256
using inner_backstrides_type = backstrides_type;
257257

258258
// NOTE: 0D (S::size() == 0) results in storage for 1 element (scalar)
259-
#if defined(_MSC_VER) && _MSC_VER < 1910 && !defined(_WIN64)
260-
// WORKAROUND FOR MSVC 2015 32 bit, fallback to unaligned container for 0D scalar case
261-
using storage_type = std::array<ET, detail::fixed_compute_size<S>::value>;
262-
#else
263259
using storage_type = aligned_array<ET, detail::fixed_compute_size<S>::value>;
264-
#endif
265260

266261
using reference = typename storage_type::reference;
267262
using const_reference = typename storage_type::const_reference;

include/xtensor/containers/xstorage.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,13 +649,9 @@ namespace xt
649649
using reverse_iterator = std::reverse_iterator<iterator>;
650650
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
651651

652-
#if defined(_MSC_VER) && _MSC_VER < 1910
653-
static constexpr std::size_t alignment = detail::allocator_alignment<A>::value;
654-
#else
655652
static constexpr std::size_t alignment = detail::allocator_alignment<A>::value != 0
656653
? detail::allocator_alignment<A>::value
657654
: alignof(T);
658-
#endif
659655

660656
svector() noexcept;
661657
~svector();

include/xtensor/core/xiterable.hpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -322,21 +322,6 @@ namespace xt
322322

323323
static constexpr layout_type static_layout = inner_types::layout;
324324

325-
#if defined(_MSC_VER) && _MSC_VER >= 1910
326-
// Workaround for compiler bug in Visual Studio 2017 with respect to alias templates with non-type
327-
// parameters.
328-
template <layout_type L>
329-
using layout_iterator = xiterator<typename iterable_base::stepper, typename iterable_base::inner_shape_type*, L>;
330-
template <layout_type L>
331-
using const_layout_iterator = xiterator<
332-
typename iterable_base::const_stepper,
333-
typename iterable_base::inner_shape_type*,
334-
L>;
335-
template <layout_type L>
336-
using reverse_layout_iterator = std::reverse_iterator<layout_iterator<L>>;
337-
template <layout_type L>
338-
using const_reverse_layout_iterator = std::reverse_iterator<const_layout_iterator<L>>;
339-
#else
340325
template <layout_type L>
341326
using layout_iterator = typename iterable_base::template layout_iterator<L>;
342327
template <layout_type L>
@@ -345,7 +330,6 @@ namespace xt
345330
using reverse_layout_iterator = typename iterable_base::template reverse_layout_iterator<L>;
346331
template <layout_type L>
347332
using const_reverse_layout_iterator = typename iterable_base::template const_reverse_layout_iterator<L>;
348-
#endif
349333

350334
template <class S, layout_type L>
351335
using broadcast_iterator = typename iterable_base::template broadcast_iterator<S, L>;

include/xtensor/core/xmath.hpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,31 +1088,6 @@ namespace xt
10881088
return xfunction_type(detail::lambda_adapt<F>(std::forward<F>(lambda)), std::forward<E>(args)...);
10891089
}
10901090

1091-
// Workaround for MSVC 2015 & GCC 4.9
1092-
#if (defined(_MSC_VER) && _MSC_VER < 1910) || (defined(__GNUC__) && __GNUC__ < 5)
1093-
#define XTENSOR_DISABLE_LAMBDA_FCT
1094-
#endif
1095-
1096-
#ifdef XTENSOR_DISABLE_LAMBDA_FCT
1097-
struct square_fct
1098-
{
1099-
template <class T>
1100-
auto operator()(T x) const -> decltype(x * x)
1101-
{
1102-
return x * x;
1103-
}
1104-
};
1105-
1106-
struct cube_fct
1107-
{
1108-
template <class T>
1109-
auto operator()(T x) const -> decltype(x * x * x)
1110-
{
1111-
return x * x * x;
1112-
}
1113-
};
1114-
#endif
1115-
11161091
/**
11171092
* @ingroup pow_functions
11181093
* @brief Square power function, equivalent to e1 * e1.
@@ -1125,15 +1100,11 @@ namespace xt
11251100
template <class E1>
11261101
inline auto square(E1&& e1) noexcept
11271102
{
1128-
#ifdef XTENSOR_DISABLE_LAMBDA_FCT
1129-
return make_lambda_xfunction(square_fct{}, std::forward<E1>(e1));
1130-
#else
11311103
auto fnct = [](auto x) -> decltype(x * x)
11321104
{
11331105
return x * x;
11341106
};
11351107
return make_lambda_xfunction(std::move(fnct), std::forward<E1>(e1));
1136-
#endif
11371108
}
11381109

11391110
/**
@@ -1148,19 +1119,13 @@ namespace xt
11481119
template <class E1>
11491120
inline auto cube(E1&& e1) noexcept
11501121
{
1151-
#ifdef XTENSOR_DISABLE_LAMBDA_FCT
1152-
return make_lambda_xfunction(cube_fct{}, std::forward<E1>(e1));
1153-
#else
11541122
auto fnct = [](auto x) -> decltype(x * x * x)
11551123
{
11561124
return x * x * x;
11571125
};
11581126
return make_lambda_xfunction(std::move(fnct), std::forward<E1>(e1));
1159-
#endif
11601127
}
11611128

1162-
#undef XTENSOR_DISABLE_LAMBDA_FCT
1163-
11641129
namespace detail
11651130
{
11661131
// Thanks to Matt Pharr in http://pbrt.org/hair.pdf

include/xtensor/core/xvectorize.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,9 @@ namespace xt
5454
template <class F, class R, class... Args>
5555
xvectorizer<F, R> vectorize(F&& f, R (*)(Args...));
5656

57-
// Workaround for Visual Studio 15.7.1.
58-
// Error C2668 (ambiguous call to overloaded function) mistaking a declarations
59-
// for the definition of another overload.
60-
#ifndef _MSC_VER
6157
template <class F>
6258
auto vectorize(F&& f)
6359
-> decltype(vectorize(std::forward<F>(f), std::declval<detail::get_function_type<F>*>()));
64-
#endif
6560

6661
/******************************
6762
* xvectorizer implementation *

include/xtensor/generators/xbuilder.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -954,17 +954,10 @@ namespace xt
954954
template <std::size_t... I, class... E>
955955
inline auto meshgrid_impl(std::index_sequence<I...>, E&&... e) noexcept
956956
{
957-
#if defined _MSC_VER
958-
const std::array<std::size_t, sizeof...(E)> shape = {e.shape()[0]...};
959-
return std::make_tuple(
960-
detail::make_xgenerator(detail::repeat_impl<xclosure_t<E>>(std::forward<E>(e), I), shape)...
961-
);
962-
#else
963957
return std::make_tuple(detail::make_xgenerator(
964958
detail::repeat_impl<xclosure_t<E>>(std::forward<E>(e), I),
965959
{e.shape()[0]...}
966960
)...);
967-
#endif
968961
}
969962
}
970963

include/xtensor/io/xinfo.hpp

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,49 +14,21 @@
1414

1515
#include "../core/xlayout.hpp"
1616

17-
#ifndef _MSC_VER
18-
#if __cplusplus < 201103
19-
#define CONSTEXPR11_TN
20-
#define CONSTEXPR14_TN
21-
#define NOEXCEPT_TN
22-
#elif __cplusplus < 201402
23-
#define CONSTEXPR11_TN constexpr
24-
#define CONSTEXPR14_TN
25-
#define NOEXCEPT_TN noexcept
26-
#else
27-
#define CONSTEXPR11_TN constexpr
28-
#define CONSTEXPR14_TN constexpr
29-
#define NOEXCEPT_TN noexcept
30-
#endif
31-
#else // _MSC_VER
32-
#if _MSC_VER < 1900
33-
#define CONSTEXPR11_TN
34-
#define CONSTEXPR14_TN
35-
#define NOEXCEPT_TN
36-
#elif _MSC_VER < 2000
37-
#define CONSTEXPR11_TN constexpr
38-
#define CONSTEXPR14_TN
39-
#define NOEXCEPT_TN noexcept
40-
#else
41-
#define CONSTEXPR11_TN constexpr
42-
#define CONSTEXPR14_TN constexpr
43-
#define NOEXCEPT_TN noexcept
44-
#endif
45-
#endif
46-
4717
namespace xt
4818
{
4919
// see http://stackoverflow.com/a/20170989
5020
struct static_string
5121
{
5222
template <std::size_t N>
53-
explicit CONSTEXPR11_TN static_string(const char (&a)[N]) NOEXCEPT_TN : data(a),
54-
size(N - 1)
23+
explicit constexpr static_string(const char (&a)[N]) noexcept
24+
: data(a)
25+
, size(N - 1)
5526
{
5627
}
5728

58-
CONSTEXPR11_TN static_string(const char* a, const std::size_t sz) NOEXCEPT_TN : data(a),
59-
size(sz)
29+
constexpr static_string(const char* a, const std::size_t sz) noexcept
30+
: data(a)
31+
, size(sz)
6032
{
6133
}
6234

@@ -65,18 +37,14 @@ namespace xt
6537
};
6638

6739
template <class T>
68-
CONSTEXPR14_TN static_string type_name()
40+
constexpr static_string type_name()
6941
{
7042
#ifdef __clang__
7143
static_string p(__PRETTY_FUNCTION__);
7244
return static_string(p.data + 39, p.size - 39 - 1);
7345
#elif defined(__GNUC__)
7446
static_string p(__PRETTY_FUNCTION__);
75-
#if __cplusplus < 201402
76-
return static_string(p.data + 36, p.size - 36 - 1);
77-
#else
7847
return static_string(p.data + 54, p.size - 54 - 1);
79-
#endif
8048
#elif defined(_MSC_VER)
8149
static const static_string p(__FUNCSIG__);
8250
return static_string(p.data + 47, p.size - 47 - 7);

include/xtensor/utils/xutils.hpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@
2828

2929
#include "../core/xtensor_config.hpp"
3030

31-
#if (defined(_MSC_VER) && _MSC_VER >= 1910)
32-
#define NOEXCEPT(T)
33-
#else
34-
#define NOEXCEPT(T) noexcept(T)
35-
#endif
36-
3731
namespace xt
3832
{
3933
/****************
@@ -53,7 +47,7 @@ namespace xt
5347
constexpr decltype(auto) argument(Args&&... args) noexcept;
5448

5549
template <class R, class F, class... S>
56-
R apply(std::size_t index, F&& func, const std::tuple<S...>& s) NOEXCEPT(noexcept(func(std::get<0>(s))));
50+
R apply(std::size_t index, F&& func, const std::tuple<S...>& s) noexcept(noexcept(func(std::get<0>(s))));
5751

5852
template <class T, class S>
5953
void nested_copy(T&& iter, const S& s);
@@ -198,7 +192,7 @@ namespace xt
198192
* accumulate implementation *
199193
*****************************/
200194

201-
/// @cond DOXYGEN_INCLUDE_NOEXCEPT
195+
/// @cond DOXYGEN_INCLUDE_noexcept
202196

203197
namespace detail
204198
{
@@ -266,8 +260,8 @@ namespace xt
266260
************************/
267261

268262
template <class R, class F, class... S>
269-
inline R apply(std::size_t index, F&& func, const std::tuple<S...>& s)
270-
NOEXCEPT(noexcept(func(std::get<0>(s))))
263+
inline R
264+
apply(std::size_t index, F&& func, const std::tuple<S...>& s) noexcept(noexcept(func(std::get<0>(s))))
271265
{
272266
XTENSOR_ASSERT(sizeof...(S) > index);
273267
return std::apply(

test/test_xdatesupport.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ namespace xt
5555
EXPECT_EQ((result < result2), expected);
5656
}
5757

58-
// need to wait until the system clock on Windows catches up with Linux
59-
#ifndef _MSC_VER
6058
TEST(xdate, date_arange)
6159
{
6260
xarray<tp> tarr = xt::arange<tp>(
@@ -66,7 +64,6 @@ namespace xt
6664
);
6765
EXPECT_TRUE(tarr.storage().back() > tarr.storage().front());
6866
}
69-
#endif
7067

7168
TEST(xdate, xfunction)
7269
{

test/test_xfunction.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -480,21 +480,13 @@ namespace xt
480480
auto f1 = 2.0 * x;
481481
auto f2 = x * 2.0 * x;
482482
iterator_tester(f1);
483-
// For an unknown reason, MSVC cannot correctly generate
484-
// linear_cbegin() for a function of function. Moreover,
485-
// a simple SFINAE deduction like has_linear_iterator
486-
// harcoded and tested here fails (while it builds fine in any
487-
// empty project)
488-
#ifndef _MSC_VER
489483
iterator_tester(f2);
490484
iterator_tester(x * y * 3.0);
491485
iterator_tester(5.0 + x * y * 3.0);
492486
iterator_tester(x * y * z);
493487
iterator_tester(x / y / z);
494-
#endif
495488
}
496489

497-
#ifndef _MSC_VER
498490
TEST(xfunction, xfunction_in_xfunction)
499491
{
500492
using Point3 = xt::xtensor_fixed<double, xshape<3>>;
@@ -507,5 +499,4 @@ namespace xt
507499
xtensor<Point3, 1> res{r1, r2, r3};
508500
EXPECT_EQ(c, res);
509501
}
510-
#endif
511502
}

0 commit comments

Comments
 (0)