diff --git a/include/xtensor/containers/xcontainer.hpp b/include/xtensor/containers/xcontainer.hpp index bfaf54b5a..a2ab4fd0d 100644 --- a/include/xtensor/containers/xcontainer.hpp +++ b/include/xtensor/containers/xcontainer.hpp @@ -114,11 +114,11 @@ namespace xt size_type size() const noexcept; - XTENSOR_CONSTEXPR_RETURN size_type dimension() const noexcept; + constexpr size_type dimension() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_shape_type& shape() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_strides_type& strides() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_backstrides_type& backstrides() const noexcept; + constexpr const inner_shape_type& shape() const noexcept; + constexpr const inner_strides_type& strides() const noexcept; + constexpr const inner_backstrides_type& backstrides() const noexcept; template void fill(const T& value); @@ -373,7 +373,7 @@ namespace xt * Returns the number of dimensions of the container. */ template - XTENSOR_CONSTEXPR_RETURN auto xcontainer::dimension() const noexcept -> size_type + constexpr auto xcontainer::dimension() const noexcept -> size_type { return shape().size(); } @@ -382,7 +382,7 @@ namespace xt * Returns the shape of the container. */ template - XTENSOR_CONSTEXPR_RETURN auto xcontainer::shape() const noexcept -> const inner_shape_type& + constexpr auto xcontainer::shape() const noexcept -> const inner_shape_type& { return derived_cast().shape_impl(); } @@ -391,7 +391,7 @@ namespace xt * Returns the strides of the container. */ template - XTENSOR_CONSTEXPR_RETURN auto xcontainer::strides() const noexcept -> const inner_strides_type& + constexpr auto xcontainer::strides() const noexcept -> const inner_strides_type& { return derived_cast().strides_impl(); } @@ -400,7 +400,7 @@ namespace xt * Returns the backstrides of the container. */ template - XTENSOR_CONSTEXPR_RETURN auto xcontainer::backstrides() const noexcept -> const inner_backstrides_type& + constexpr auto xcontainer::backstrides() const noexcept -> const inner_backstrides_type& { return derived_cast().backstrides_impl(); } diff --git a/include/xtensor/containers/xfixed.hpp b/include/xtensor/containers/xfixed.hpp index 25c9c747d..54270caa7 100644 --- a/include/xtensor/containers/xfixed.hpp +++ b/include/xtensor/containers/xfixed.hpp @@ -373,9 +373,9 @@ namespace xt storage_type& storage_impl() noexcept; const storage_type& storage_impl() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_shape_type& shape_impl() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_strides_type& strides_impl() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_backstrides_type& backstrides_impl() const noexcept; + constexpr const inner_shape_type& shape_impl() const noexcept; + constexpr const inner_strides_type& strides_impl() const noexcept; + constexpr const inner_backstrides_type& backstrides_impl() const noexcept; friend class xcontainer>; }; @@ -495,9 +495,9 @@ namespace xt storage_type& storage_impl() noexcept; const storage_type& storage_impl() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_shape_type& shape_impl() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_strides_type& strides_impl() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_backstrides_type& backstrides_impl() const noexcept; + constexpr const inner_shape_type& shape_impl() const noexcept; + constexpr const inner_strides_type& strides_impl() const noexcept; + constexpr const inner_backstrides_type& backstrides_impl() const noexcept; friend class xcontainer>; }; @@ -740,21 +740,20 @@ namespace xt } template - XTENSOR_CONSTEXPR_RETURN auto xfixed_container::shape_impl() const noexcept - -> const inner_shape_type& + constexpr auto xfixed_container::shape_impl() const noexcept -> const inner_shape_type& { return m_shape; } template - XTENSOR_CONSTEXPR_RETURN auto xfixed_container::strides_impl() const noexcept + constexpr auto xfixed_container::strides_impl() const noexcept -> const inner_strides_type& { return m_strides; } template - XTENSOR_CONSTEXPR_RETURN auto xfixed_container::backstrides_impl() const noexcept + constexpr auto xfixed_container::backstrides_impl() const noexcept -> const inner_backstrides_type& { return m_backstrides; @@ -937,21 +936,20 @@ namespace xt } template - XTENSOR_CONSTEXPR_RETURN auto xfixed_adaptor::shape_impl() const noexcept - -> const inner_shape_type& + constexpr auto xfixed_adaptor::shape_impl() const noexcept -> const inner_shape_type& { return m_shape; } template - XTENSOR_CONSTEXPR_RETURN auto xfixed_adaptor::strides_impl() const noexcept + constexpr auto xfixed_adaptor::strides_impl() const noexcept -> const inner_strides_type& { return m_strides; } template - XTENSOR_CONSTEXPR_RETURN auto xfixed_adaptor::backstrides_impl() const noexcept + constexpr auto xfixed_adaptor::backstrides_impl() const noexcept -> const inner_backstrides_type& { return m_backstrides; diff --git a/include/xtensor/containers/xscalar.hpp b/include/xtensor/containers/xscalar.hpp index 4a9c01081..106a65923 100644 --- a/include/xtensor/containers/xscalar.hpp +++ b/include/xtensor/containers/xscalar.hpp @@ -466,25 +466,25 @@ namespace xt *****************************/ template - XTENSOR_CONSTEXPR_RETURN auto linear_begin(xscalar& c) noexcept -> decltype(c.dummy_begin()) + constexpr auto linear_begin(xscalar& c) noexcept -> decltype(c.dummy_begin()) { return c.dummy_begin(); } template - XTENSOR_CONSTEXPR_RETURN auto linear_end(xscalar& c) noexcept -> decltype(c.dummy_end()) + constexpr auto linear_end(xscalar& c) noexcept -> decltype(c.dummy_end()) { return c.dummy_end(); } template - XTENSOR_CONSTEXPR_RETURN auto linear_begin(const xscalar& c) noexcept -> decltype(c.dummy_begin()) + constexpr auto linear_begin(const xscalar& c) noexcept -> decltype(c.dummy_begin()) { return c.dummy_begin(); } template - XTENSOR_CONSTEXPR_RETURN auto linear_end(const xscalar& c) noexcept -> decltype(c.dummy_end()) + constexpr auto linear_end(const xscalar& c) noexcept -> decltype(c.dummy_end()) { return c.dummy_end(); } diff --git a/include/xtensor/containers/xstorage.hpp b/include/xtensor/containers/xstorage.hpp index 811ab80b7..426480805 100644 --- a/include/xtensor/containers/xstorage.hpp +++ b/include/xtensor/containers/xstorage.hpp @@ -1658,13 +1658,7 @@ namespace xt { public: -#if defined(_MSC_VER) - using cast_type = std::array; -#define XTENSOR_FIXED_SHAPE_CONSTEXPR inline -#else using cast_type = const_array; -#define XTENSOR_FIXED_SHAPE_CONSTEXPR constexpr -#endif using value_type = std::size_t; using size_type = std::size_t; using const_iterator = typename cast_type::const_iterator; @@ -1681,17 +1675,17 @@ namespace xt return std::get(tmp_cast_type{X...}); } - XTENSOR_FIXED_SHAPE_CONSTEXPR operator cast_type() const + constexpr operator cast_type() const { return cast_type({X...}); } - XTENSOR_FIXED_SHAPE_CONSTEXPR auto begin() const + constexpr auto begin() const { return m_array.begin(); } - XTENSOR_FIXED_SHAPE_CONSTEXPR auto end() const + constexpr auto end() const { return m_array.end(); } @@ -1706,22 +1700,22 @@ namespace xt return m_array.rend(); } - XTENSOR_FIXED_SHAPE_CONSTEXPR auto cbegin() const + constexpr auto cbegin() const { return m_array.cbegin(); } - XTENSOR_FIXED_SHAPE_CONSTEXPR auto cend() const + constexpr auto cend() const { return m_array.cend(); } - XTENSOR_FIXED_SHAPE_CONSTEXPR std::size_t operator[](std::size_t idx) const + constexpr std::size_t operator[](std::size_t idx) const { return m_array[idx]; } - XTENSOR_FIXED_SHAPE_CONSTEXPR bool empty() const + constexpr bool empty() const { return sizeof...(X) == 0; } @@ -1731,8 +1725,6 @@ namespace xt XTENSOR_CONSTEXPR_ENHANCED_STATIC cast_type m_array = cast_type({X...}); }; -#undef XTENSOR_FIXED_SHAPE_CONSTEXPR - template class sequence_view { diff --git a/include/xtensor/core/xiterator.hpp b/include/xtensor/core/xiterator.hpp index 6dcb9c9e1..448f6093d 100644 --- a/include/xtensor/core/xiterator.hpp +++ b/include/xtensor/core/xiterator.hpp @@ -417,7 +417,7 @@ namespace xt } template - XTENSOR_CONSTEXPR_RETURN auto linear_begin(C& c) noexcept + constexpr auto linear_begin(C& c) noexcept { if constexpr (detail::has_linear_iterator::value) { @@ -430,7 +430,7 @@ namespace xt } template - XTENSOR_CONSTEXPR_RETURN auto linear_end(C& c) noexcept + constexpr auto linear_end(C& c) noexcept { if constexpr (detail::has_linear_iterator::value) { @@ -443,7 +443,7 @@ namespace xt } template - XTENSOR_CONSTEXPR_RETURN auto linear_begin(const C& c) noexcept + constexpr auto linear_begin(const C& c) noexcept { if constexpr (detail::has_linear_iterator::value) { @@ -456,7 +456,7 @@ namespace xt } template - XTENSOR_CONSTEXPR_RETURN auto linear_end(const C& c) noexcept + constexpr auto linear_end(const C& c) noexcept { if constexpr (detail::has_linear_iterator::value) { diff --git a/include/xtensor/core/xtensor_config.hpp b/include/xtensor/core/xtensor_config.hpp index 6a74112df..959a3b2a4 100644 --- a/include/xtensor/core/xtensor_config.hpp +++ b/include/xtensor/core/xtensor_config.hpp @@ -35,17 +35,12 @@ // Workaround for some missing constexpr functionality in MSVC 2015 and MSVC 2017 x86 #if defined(_MSC_VER) -#define XTENSOR_CONSTEXPR_ENHANCED const // The following must not be defined to const, otherwise // it prevents generation of copy operators of classes // containing XTENSOR_CONSTEXPR_ENHANCED_STATIC members #define XTENSOR_CONSTEXPR_ENHANCED_STATIC -#define XTENSOR_CONSTEXPR_RETURN inline #else -#define XTENSOR_CONSTEXPR_ENHANCED constexpr -#define XTENSOR_CONSTEXPR_RETURN constexpr #define XTENSOR_CONSTEXPR_ENHANCED_STATIC constexpr static -#define XTENSOR_HAS_CONSTEXPR_ENHANCED #endif #ifndef XTENSOR_DEFAULT_DATA_CONTAINER diff --git a/include/xtensor/views/xbroadcast.hpp b/include/xtensor/views/xbroadcast.hpp index d3034222f..68b11d443 100644 --- a/include/xtensor/views/xbroadcast.hpp +++ b/include/xtensor/views/xbroadcast.hpp @@ -96,25 +96,25 @@ namespace xt *****************************/ template - XTENSOR_CONSTEXPR_RETURN auto linear_begin(xbroadcast& c) noexcept + constexpr auto linear_begin(xbroadcast& c) noexcept { return linear_begin(c.expression()); } template - XTENSOR_CONSTEXPR_RETURN auto linear_end(xbroadcast& c) noexcept + constexpr auto linear_end(xbroadcast& c) noexcept { return linear_end(c.expression()); } template - XTENSOR_CONSTEXPR_RETURN auto linear_begin(const xbroadcast& c) noexcept + constexpr auto linear_begin(const xbroadcast& c) noexcept { return linear_begin(c.expression()); } template - XTENSOR_CONSTEXPR_RETURN auto linear_end(const xbroadcast& c) noexcept + constexpr auto linear_end(const xbroadcast& c) noexcept { return linear_end(c.expression()); } diff --git a/include/xtensor/views/xslice.hpp b/include/xtensor/views/xslice.hpp index a7a4dae6e..7b6856415 100644 --- a/include/xtensor/views/xslice.hpp +++ b/include/xtensor/views/xslice.hpp @@ -21,16 +21,6 @@ #include "../core/xtensor_config.hpp" #include "../utils/xutils.hpp" -#ifndef XTENSOR_CONSTEXPR -#if (defined(_MSC_VER) || __GNUC__ < 8) -#define XTENSOR_CONSTEXPR inline -#define XTENSOR_GLOBAL_CONSTEXPR static const -#else -#define XTENSOR_CONSTEXPR constexpr -#define XTENSOR_GLOBAL_CONSTEXPR constexpr -#endif -#endif - namespace xt { @@ -70,11 +60,11 @@ namespace xt * slice tags * **************/ -#define DEFINE_TAG_CONVERSION(NAME) \ - template \ - XTENSOR_CONSTEXPR NAME convert() const noexcept \ - { \ - return NAME(); \ +#define DEFINE_TAG_CONVERSION(NAME) \ + template \ + constexpr NAME convert() const noexcept \ + { \ + return NAME(); \ } struct xall_tag @@ -642,12 +632,12 @@ namespace xt std::ptrdiff_t rng[3]; // = { 0, 0, 0 }; }; - XTENSOR_CONSTEXPR xtuph get_tuph_or_val(std::ptrdiff_t /*val*/, std::true_type) + constexpr xtuph get_tuph_or_val(std::ptrdiff_t /*val*/, std::true_type) { return xtuph(); } - XTENSOR_CONSTEXPR std::ptrdiff_t get_tuph_or_val(std::ptrdiff_t val, std::false_type) + constexpr std::ptrdiff_t get_tuph_or_val(std::ptrdiff_t val, std::false_type) { return val; } @@ -655,7 +645,7 @@ namespace xt template struct rangemaker { - XTENSOR_CONSTEXPR operator xrange_adaptor() + constexpr operator xrange_adaptor() { return xrange_adaptor( {get_tuph_or_val(rng[0], std::is_same()), @@ -670,7 +660,7 @@ namespace xt template struct rangemaker { - XTENSOR_CONSTEXPR operator xrange_adaptor() + constexpr operator xrange_adaptor() { return xrange_adaptor( {get_tuph_or_val(rng[0], std::is_same()), @@ -683,7 +673,7 @@ namespace xt }; template - XTENSOR_CONSTEXPR auto operator|(const rangemaker& rng, const std::ptrdiff_t& t) + constexpr auto operator|(const rangemaker& rng, const std::ptrdiff_t& t) { auto nrng = rangemaker({rng.rng[0], rng.rng[1], rng.rng[2]}); nrng.rng[sizeof...(OA)] = t; @@ -691,17 +681,17 @@ namespace xt } template - XTENSOR_CONSTEXPR auto operator|(const rangemaker& rng, const xt::placeholders::xtuph& /*t*/) + constexpr auto operator|(const rangemaker& rng, const xt::placeholders::xtuph& /*t*/) { auto nrng = rangemaker({rng.rng[0], rng.rng[1], rng.rng[2]}); return nrng; } - XTENSOR_GLOBAL_CONSTEXPR xtuph _{}; - XTENSOR_GLOBAL_CONSTEXPR rangemaker<> _r = rangemaker<>({{0, 0, 0}}); - XTENSOR_GLOBAL_CONSTEXPR xall_tag _a{}; - XTENSOR_GLOBAL_CONSTEXPR xnewaxis_tag _n{}; - XTENSOR_GLOBAL_CONSTEXPR xellipsis_tag _e{}; + constexpr xtuph _{}; + constexpr rangemaker<> _r = rangemaker<>({{0, 0, 0}}); + constexpr xall_tag _a{}; + constexpr xnewaxis_tag _n{}; + constexpr xellipsis_tag _e{}; } inline auto xnone() @@ -1598,6 +1588,4 @@ namespace xt } } -#undef XTENSOR_CONSTEXPR - #endif