Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 0 additions & 66 deletions include/xtensor/containers/xstorage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1437,49 +1437,6 @@ namespace xt
#define XTENSOR_CONST const
#endif

#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__)
#define GCC4_FALLBACK

namespace const_array_detail
{
template <class T, std::size_t N>
struct array_traits
{
using storage_type = T[N];

static constexpr T& ref(const storage_type& t, std::size_t n) noexcept
{
return const_cast<T&>(t[n]);
}

static constexpr T* ptr(const storage_type& t) noexcept
{
return const_cast<T*>(t);
}
};

template <class T>
struct array_traits<T, 0>
{
struct empty
{
};

using storage_type = empty;

static constexpr T& ref(const storage_type& /*t*/, std::size_t /*n*/) noexcept
{
return *static_cast<T*>(nullptr);
}

static constexpr T* ptr(const storage_type& /*t*/) noexcept
{
return nullptr;
}
};
}
#endif

/**
* A std::array like class with all member function (except reverse iterators)
* as constexpr. The data is immutable once set.
Expand All @@ -1502,11 +1459,7 @@ namespace xt

constexpr const_reference operator[](std::size_t idx) const
{
#ifdef GCC4_FALLBACK
return const_array_detail::array_traits<T, N>::ref(m_data, idx);
#else
return m_data[idx];
#endif
}

constexpr const_iterator begin() const noexcept
Expand Down Expand Up @@ -1552,30 +1505,17 @@ namespace xt

constexpr const_pointer data() const noexcept
{
#ifdef GCC4_FALLBACK
return const_array_detail::array_traits<T, N>::ptr(m_data);
#else
return m_data;
#endif
}

constexpr const_reference front() const noexcept
{
#ifdef GCC4_FALLBACK
return const_array_detail::array_traits<T, N>::ref(m_data, 0);
#else
return m_data[0];
#endif
}

constexpr const_reference back() const noexcept
{
#ifdef GCC4_FALLBACK
return N ? const_array_detail::array_traits<T, N>::ref(m_data, N - 1)
: const_array_detail::array_traits<T, N>::ref(m_data, 0);
#else
return m_data[size() - 1];
#endif
}

constexpr bool empty() const noexcept
Expand All @@ -1588,15 +1528,9 @@ namespace xt
return N;
}

#ifdef GCC4_FALLBACK
XTENSOR_CONST typename const_array_detail::array_traits<T, N>::storage_type m_data;
#else
XTENSOR_CONST T m_data[N > 0 ? N : 1];
#endif
};

#undef GCC4_FALLBACK

template <class T, std::size_t N>
inline bool operator==(const const_array<T, N>& lhs, const const_array<T, N>& rhs)
{
Expand Down
Loading