Skip to content

Commit 4a6cbbf

Browse files
committed
Removed constexpr workarounds
1 parent 92c873e commit 4a6cbbf

7 files changed

Lines changed: 48 additions & 67 deletions

File tree

include/xtensor/containers/xcontainer.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ namespace xt
114114

115115
size_type size() const noexcept;
116116

117-
XTENSOR_CONSTEXPR_RETURN size_type dimension() const noexcept;
117+
constexpr size_type dimension() const noexcept;
118118

119-
XTENSOR_CONSTEXPR_RETURN const inner_shape_type& shape() const noexcept;
120-
XTENSOR_CONSTEXPR_RETURN const inner_strides_type& strides() const noexcept;
121-
XTENSOR_CONSTEXPR_RETURN const inner_backstrides_type& backstrides() const noexcept;
119+
constexpr const inner_shape_type& shape() const noexcept;
120+
constexpr const inner_strides_type& strides() const noexcept;
121+
constexpr const inner_backstrides_type& backstrides() const noexcept;
122122

123123
template <class T>
124124
void fill(const T& value);
@@ -373,7 +373,7 @@ namespace xt
373373
* Returns the number of dimensions of the container.
374374
*/
375375
template <class D>
376-
XTENSOR_CONSTEXPR_RETURN auto xcontainer<D>::dimension() const noexcept -> size_type
376+
constexpr auto xcontainer<D>::dimension() const noexcept -> size_type
377377
{
378378
return shape().size();
379379
}
@@ -382,7 +382,7 @@ namespace xt
382382
* Returns the shape of the container.
383383
*/
384384
template <class D>
385-
XTENSOR_CONSTEXPR_RETURN auto xcontainer<D>::shape() const noexcept -> const inner_shape_type&
385+
constexpr auto xcontainer<D>::shape() const noexcept -> const inner_shape_type&
386386
{
387387
return derived_cast().shape_impl();
388388
}
@@ -391,7 +391,7 @@ namespace xt
391391
* Returns the strides of the container.
392392
*/
393393
template <class D>
394-
XTENSOR_CONSTEXPR_RETURN auto xcontainer<D>::strides() const noexcept -> const inner_strides_type&
394+
constexpr auto xcontainer<D>::strides() const noexcept -> const inner_strides_type&
395395
{
396396
return derived_cast().strides_impl();
397397
}
@@ -400,7 +400,7 @@ namespace xt
400400
* Returns the backstrides of the container.
401401
*/
402402
template <class D>
403-
XTENSOR_CONSTEXPR_RETURN auto xcontainer<D>::backstrides() const noexcept -> const inner_backstrides_type&
403+
constexpr auto xcontainer<D>::backstrides() const noexcept -> const inner_backstrides_type&
404404
{
405405
return derived_cast().backstrides_impl();
406406
}

include/xtensor/containers/xfixed.hpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,9 @@ namespace xt
373373
storage_type& storage_impl() noexcept;
374374
const storage_type& storage_impl() const noexcept;
375375

376-
XTENSOR_CONSTEXPR_RETURN const inner_shape_type& shape_impl() const noexcept;
377-
XTENSOR_CONSTEXPR_RETURN const inner_strides_type& strides_impl() const noexcept;
378-
XTENSOR_CONSTEXPR_RETURN const inner_backstrides_type& backstrides_impl() const noexcept;
376+
constexpr const inner_shape_type& shape_impl() const noexcept;
377+
constexpr const inner_strides_type& strides_impl() const noexcept;
378+
constexpr const inner_backstrides_type& backstrides_impl() const noexcept;
379379

380380
friend class xcontainer<xfixed_container<ET, S, L, SH, Tag>>;
381381
};
@@ -495,9 +495,9 @@ namespace xt
495495
storage_type& storage_impl() noexcept;
496496
const storage_type& storage_impl() const noexcept;
497497

498-
XTENSOR_CONSTEXPR_RETURN const inner_shape_type& shape_impl() const noexcept;
499-
XTENSOR_CONSTEXPR_RETURN const inner_strides_type& strides_impl() const noexcept;
500-
XTENSOR_CONSTEXPR_RETURN const inner_backstrides_type& backstrides_impl() const noexcept;
498+
constexpr const inner_shape_type& shape_impl() const noexcept;
499+
constexpr const inner_strides_type& strides_impl() const noexcept;
500+
constexpr const inner_backstrides_type& backstrides_impl() const noexcept;
501501

502502
friend class xcontainer<xfixed_adaptor<EC, S, L, SH, Tag>>;
503503
};
@@ -740,21 +740,20 @@ namespace xt
740740
}
741741

742742
template <class ET, class S, layout_type L, bool SH, class Tag>
743-
XTENSOR_CONSTEXPR_RETURN auto xfixed_container<ET, S, L, SH, Tag>::shape_impl() const noexcept
744-
-> const inner_shape_type&
743+
constexpr auto xfixed_container<ET, S, L, SH, Tag>::shape_impl() const noexcept -> const inner_shape_type&
745744
{
746745
return m_shape;
747746
}
748747

749748
template <class ET, class S, layout_type L, bool SH, class Tag>
750-
XTENSOR_CONSTEXPR_RETURN auto xfixed_container<ET, S, L, SH, Tag>::strides_impl() const noexcept
749+
constexpr auto xfixed_container<ET, S, L, SH, Tag>::strides_impl() const noexcept
751750
-> const inner_strides_type&
752751
{
753752
return m_strides;
754753
}
755754

756755
template <class ET, class S, layout_type L, bool SH, class Tag>
757-
XTENSOR_CONSTEXPR_RETURN auto xfixed_container<ET, S, L, SH, Tag>::backstrides_impl() const noexcept
756+
constexpr auto xfixed_container<ET, S, L, SH, Tag>::backstrides_impl() const noexcept
758757
-> const inner_backstrides_type&
759758
{
760759
return m_backstrides;
@@ -937,21 +936,20 @@ namespace xt
937936
}
938937

939938
template <class EC, class S, layout_type L, bool SH, class Tag>
940-
XTENSOR_CONSTEXPR_RETURN auto xfixed_adaptor<EC, S, L, SH, Tag>::shape_impl() const noexcept
941-
-> const inner_shape_type&
939+
constexpr auto xfixed_adaptor<EC, S, L, SH, Tag>::shape_impl() const noexcept -> const inner_shape_type&
942940
{
943941
return m_shape;
944942
}
945943

946944
template <class EC, class S, layout_type L, bool SH, class Tag>
947-
XTENSOR_CONSTEXPR_RETURN auto xfixed_adaptor<EC, S, L, SH, Tag>::strides_impl() const noexcept
945+
constexpr auto xfixed_adaptor<EC, S, L, SH, Tag>::strides_impl() const noexcept
948946
-> const inner_strides_type&
949947
{
950948
return m_strides;
951949
}
952950

953951
template <class EC, class S, layout_type L, bool SH, class Tag>
954-
XTENSOR_CONSTEXPR_RETURN auto xfixed_adaptor<EC, S, L, SH, Tag>::backstrides_impl() const noexcept
952+
constexpr auto xfixed_adaptor<EC, S, L, SH, Tag>::backstrides_impl() const noexcept
955953
-> const inner_backstrides_type&
956954
{
957955
return m_backstrides;

include/xtensor/containers/xscalar.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,25 +466,25 @@ namespace xt
466466
*****************************/
467467

468468
template <class CT>
469-
XTENSOR_CONSTEXPR_RETURN auto linear_begin(xscalar<CT>& c) noexcept -> decltype(c.dummy_begin())
469+
constexpr auto linear_begin(xscalar<CT>& c) noexcept -> decltype(c.dummy_begin())
470470
{
471471
return c.dummy_begin();
472472
}
473473

474474
template <class CT>
475-
XTENSOR_CONSTEXPR_RETURN auto linear_end(xscalar<CT>& c) noexcept -> decltype(c.dummy_end())
475+
constexpr auto linear_end(xscalar<CT>& c) noexcept -> decltype(c.dummy_end())
476476
{
477477
return c.dummy_end();
478478
}
479479

480480
template <class CT>
481-
XTENSOR_CONSTEXPR_RETURN auto linear_begin(const xscalar<CT>& c) noexcept -> decltype(c.dummy_begin())
481+
constexpr auto linear_begin(const xscalar<CT>& c) noexcept -> decltype(c.dummy_begin())
482482
{
483483
return c.dummy_begin();
484484
}
485485

486486
template <class CT>
487-
XTENSOR_CONSTEXPR_RETURN auto linear_end(const xscalar<CT>& c) noexcept -> decltype(c.dummy_end())
487+
constexpr auto linear_end(const xscalar<CT>& c) noexcept -> decltype(c.dummy_end())
488488
{
489489
return c.dummy_end();
490490
}

include/xtensor/core/xiterator.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ namespace xt
417417
}
418418

419419
template <class C>
420-
XTENSOR_CONSTEXPR_RETURN auto linear_begin(C& c) noexcept
420+
constexpr auto linear_begin(C& c) noexcept
421421
{
422422
if constexpr (detail::has_linear_iterator<C>::value)
423423
{
@@ -430,7 +430,7 @@ namespace xt
430430
}
431431

432432
template <class C>
433-
XTENSOR_CONSTEXPR_RETURN auto linear_end(C& c) noexcept
433+
constexpr auto linear_end(C& c) noexcept
434434
{
435435
if constexpr (detail::has_linear_iterator<C>::value)
436436
{
@@ -443,7 +443,7 @@ namespace xt
443443
}
444444

445445
template <class C>
446-
XTENSOR_CONSTEXPR_RETURN auto linear_begin(const C& c) noexcept
446+
constexpr auto linear_begin(const C& c) noexcept
447447
{
448448
if constexpr (detail::has_linear_iterator<C>::value)
449449
{
@@ -456,7 +456,7 @@ namespace xt
456456
}
457457

458458
template <class C>
459-
XTENSOR_CONSTEXPR_RETURN auto linear_end(const C& c) noexcept
459+
constexpr auto linear_end(const C& c) noexcept
460460
{
461461
if constexpr (detail::has_linear_iterator<C>::value)
462462
{

include/xtensor/core/xtensor_config.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,12 @@
3535

3636
// Workaround for some missing constexpr functionality in MSVC 2015 and MSVC 2017 x86
3737
#if defined(_MSC_VER)
38-
#define XTENSOR_CONSTEXPR_ENHANCED const
3938
// The following must not be defined to const, otherwise
4039
// it prevents generation of copy operators of classes
4140
// containing XTENSOR_CONSTEXPR_ENHANCED_STATIC members
4241
#define XTENSOR_CONSTEXPR_ENHANCED_STATIC
43-
#define XTENSOR_CONSTEXPR_RETURN inline
4442
#else
45-
#define XTENSOR_CONSTEXPR_ENHANCED constexpr
46-
#define XTENSOR_CONSTEXPR_RETURN constexpr
4743
#define XTENSOR_CONSTEXPR_ENHANCED_STATIC constexpr static
48-
#define XTENSOR_HAS_CONSTEXPR_ENHANCED
4944
#endif
5045

5146
#ifndef XTENSOR_DEFAULT_DATA_CONTAINER

include/xtensor/views/xbroadcast.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,25 +96,25 @@ namespace xt
9696
*****************************/
9797

9898
template <class CT, class X>
99-
XTENSOR_CONSTEXPR_RETURN auto linear_begin(xbroadcast<CT, X>& c) noexcept
99+
constexpr auto linear_begin(xbroadcast<CT, X>& c) noexcept
100100
{
101101
return linear_begin(c.expression());
102102
}
103103

104104
template <class CT, class X>
105-
XTENSOR_CONSTEXPR_RETURN auto linear_end(xbroadcast<CT, X>& c) noexcept
105+
constexpr auto linear_end(xbroadcast<CT, X>& c) noexcept
106106
{
107107
return linear_end(c.expression());
108108
}
109109

110110
template <class CT, class X>
111-
XTENSOR_CONSTEXPR_RETURN auto linear_begin(const xbroadcast<CT, X>& c) noexcept
111+
constexpr auto linear_begin(const xbroadcast<CT, X>& c) noexcept
112112
{
113113
return linear_begin(c.expression());
114114
}
115115

116116
template <class CT, class X>
117-
XTENSOR_CONSTEXPR_RETURN auto linear_end(const xbroadcast<CT, X>& c) noexcept
117+
constexpr auto linear_end(const xbroadcast<CT, X>& c) noexcept
118118
{
119119
return linear_end(c.expression());
120120
}

include/xtensor/views/xslice.hpp

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@
2121
#include "../core/xtensor_config.hpp"
2222
#include "../utils/xutils.hpp"
2323

24-
#ifndef XTENSOR_CONSTEXPR
25-
#if (defined(_MSC_VER) || __GNUC__ < 8)
26-
#define XTENSOR_CONSTEXPR inline
27-
#define XTENSOR_GLOBAL_CONSTEXPR static const
28-
#else
29-
#define XTENSOR_CONSTEXPR constexpr
30-
#define XTENSOR_GLOBAL_CONSTEXPR constexpr
31-
#endif
32-
#endif
33-
3424
namespace xt
3525
{
3626

@@ -70,11 +60,11 @@ namespace xt
7060
* slice tags *
7161
**************/
7262

73-
#define DEFINE_TAG_CONVERSION(NAME) \
74-
template <class T> \
75-
XTENSOR_CONSTEXPR NAME convert() const noexcept \
76-
{ \
77-
return NAME(); \
63+
#define DEFINE_TAG_CONVERSION(NAME) \
64+
template <class T> \
65+
constexpr NAME convert() const noexcept \
66+
{ \
67+
return NAME(); \
7868
}
7969

8070
struct xall_tag
@@ -642,20 +632,20 @@ namespace xt
642632
std::ptrdiff_t rng[3]; // = { 0, 0, 0 };
643633
};
644634

645-
XTENSOR_CONSTEXPR xtuph get_tuph_or_val(std::ptrdiff_t /*val*/, std::true_type)
635+
constexpr xtuph get_tuph_or_val(std::ptrdiff_t /*val*/, std::true_type)
646636
{
647637
return xtuph();
648638
}
649639

650-
XTENSOR_CONSTEXPR std::ptrdiff_t get_tuph_or_val(std::ptrdiff_t val, std::false_type)
640+
constexpr std::ptrdiff_t get_tuph_or_val(std::ptrdiff_t val, std::false_type)
651641
{
652642
return val;
653643
}
654644

655645
template <class A, class B, class C>
656646
struct rangemaker<A, B, C>
657647
{
658-
XTENSOR_CONSTEXPR operator xrange_adaptor<A, B, C>()
648+
constexpr operator xrange_adaptor<A, B, C>()
659649
{
660650
return xrange_adaptor<A, B, C>(
661651
{get_tuph_or_val(rng[0], std::is_same<A, xtuph>()),
@@ -670,7 +660,7 @@ namespace xt
670660
template <class A, class B>
671661
struct rangemaker<A, B>
672662
{
673-
XTENSOR_CONSTEXPR operator xrange_adaptor<A, B, xt::placeholders::xtuph>()
663+
constexpr operator xrange_adaptor<A, B, xt::placeholders::xtuph>()
674664
{
675665
return xrange_adaptor<A, B, xt::placeholders::xtuph>(
676666
{get_tuph_or_val(rng[0], std::is_same<A, xtuph>()),
@@ -683,25 +673,25 @@ namespace xt
683673
};
684674

685675
template <class... OA>
686-
XTENSOR_CONSTEXPR auto operator|(const rangemaker<OA...>& rng, const std::ptrdiff_t& t)
676+
constexpr auto operator|(const rangemaker<OA...>& rng, const std::ptrdiff_t& t)
687677
{
688678
auto nrng = rangemaker<OA..., std::ptrdiff_t>({rng.rng[0], rng.rng[1], rng.rng[2]});
689679
nrng.rng[sizeof...(OA)] = t;
690680
return nrng;
691681
}
692682

693683
template <class... OA>
694-
XTENSOR_CONSTEXPR auto operator|(const rangemaker<OA...>& rng, const xt::placeholders::xtuph& /*t*/)
684+
constexpr auto operator|(const rangemaker<OA...>& rng, const xt::placeholders::xtuph& /*t*/)
695685
{
696686
auto nrng = rangemaker<OA..., xt::placeholders::xtuph>({rng.rng[0], rng.rng[1], rng.rng[2]});
697687
return nrng;
698688
}
699689

700-
XTENSOR_GLOBAL_CONSTEXPR xtuph _{};
701-
XTENSOR_GLOBAL_CONSTEXPR rangemaker<> _r = rangemaker<>({{0, 0, 0}});
702-
XTENSOR_GLOBAL_CONSTEXPR xall_tag _a{};
703-
XTENSOR_GLOBAL_CONSTEXPR xnewaxis_tag _n{};
704-
XTENSOR_GLOBAL_CONSTEXPR xellipsis_tag _e{};
690+
constexpr xtuph _{};
691+
constexpr rangemaker<> _r = rangemaker<>({{0, 0, 0}});
692+
constexpr xall_tag _a{};
693+
constexpr xnewaxis_tag _n{};
694+
constexpr xellipsis_tag _e{};
705695
}
706696

707697
inline auto xnone()
@@ -1598,6 +1588,4 @@ namespace xt
15981588
}
15991589
}
16001590

1601-
#undef XTENSOR_CONSTEXPR
1602-
16031591
#endif

0 commit comments

Comments
 (0)