mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-27 12:58:43 +08:00
Merge remote-tracking branch 'origin/hotfix/remove_const_array_view' into development
This commit is contained in:
commit
61301d4fc9
@ -27,6 +27,9 @@ if (${ETL_PROFILE} STREQUAL DEFAULT)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
set(ETL_PROFILE "PROFILE_GCC_GENERIC")
|
||||
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(ETL_PROFILE "PROFILE_CLANG_GENERIC")
|
||||
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
set(ETL_PROFILE "PROFILE_MSVC")
|
||||
|
||||
|
||||
@ -486,335 +486,6 @@ namespace etl
|
||||
T* mend;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// Constant array view.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
class const_array_view
|
||||
{
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef size_t size_type;
|
||||
typedef const T& const_reference;
|
||||
typedef const T* const_pointer;
|
||||
typedef const T* const_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
//*************************************************************************
|
||||
/// Default constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR const_array_view()
|
||||
: mbegin(nullptr),
|
||||
mend(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Construct from std::array or etl::array or other type that supports
|
||||
/// data() and size() member functions.
|
||||
//*************************************************************************
|
||||
template <typename TArray>
|
||||
ETL_CONSTEXPR explicit const_array_view(TArray& a)
|
||||
: mbegin(a.data()),
|
||||
mend(a.data() + a.size())
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Construct from iterators
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
ETL_CONSTEXPR const_array_view(TIterator begin_, TIterator end_)
|
||||
: mbegin(etl::addressof(*begin_)),
|
||||
mend(etl::addressof(*begin_) + std::distance(begin_, end_))
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Construct from C array
|
||||
//*************************************************************************
|
||||
template <typename TIterator,
|
||||
typename TSize>
|
||||
ETL_CONSTEXPR const_array_view(TIterator begin_, TSize size_)
|
||||
: mbegin(etl::addressof(*begin_)),
|
||||
mend(etl::addressof(*begin_) + size_)
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Construct from C array
|
||||
//*************************************************************************
|
||||
template<const size_t ARRAY_SIZE>
|
||||
ETL_CONSTEXPR explicit const_array_view(const T(&begin_)[ARRAY_SIZE])
|
||||
: mbegin(begin_),
|
||||
mend(begin_ + ARRAY_SIZE)
|
||||
{
|
||||
}
|
||||
|
||||
//************0*************************************************************
|
||||
/// Copy constructor
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR const_array_view(const array_view<T>& other)
|
||||
: mbegin(other.begin()),
|
||||
mend(other.end())
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Copy constructor
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR const_array_view(const const_array_view& other)
|
||||
: mbegin(other.mbegin),
|
||||
mend(other.mend)
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const reference to the first element.
|
||||
//*************************************************************************
|
||||
const_reference front() const
|
||||
{
|
||||
return *mbegin;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const reference to the last element.
|
||||
//*************************************************************************
|
||||
const_reference back() const
|
||||
{
|
||||
return *(mend - 1);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const pointer to the first element of the internal storage.
|
||||
//*************************************************************************
|
||||
const_pointer data() const
|
||||
{
|
||||
return mbegin;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const iterator to the beginning of the array.
|
||||
//*************************************************************************
|
||||
const_iterator begin() const
|
||||
{
|
||||
return mbegin;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const iterator to the beginning of the array.
|
||||
//*************************************************************************
|
||||
const_iterator cbegin() const
|
||||
{
|
||||
return mbegin;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
const_iterator end() const
|
||||
{
|
||||
return mend;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// Returns a const iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
const_iterator cend() const
|
||||
{
|
||||
return mend;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const reverse iterator to the reverse beginning of the array.
|
||||
//*************************************************************************
|
||||
const_reverse_iterator rbegin() const
|
||||
{
|
||||
return const_reverse_iterator(mend);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const reverse iterator to the reverse beginning of the array.
|
||||
//*************************************************************************
|
||||
const_reverse_iterator crbegin() const
|
||||
{
|
||||
return const_reverse_iterator(mend);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const reverse iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
const_reverse_iterator rend() const
|
||||
{
|
||||
return const_reverse_iterator(mbegin);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const reverse iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
const_reverse_iterator crend() const
|
||||
{
|
||||
return const_reverse_iterator(mbegin);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// Capacity
|
||||
//*************************************************************************
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns <b>true</b> if the array size is zero.
|
||||
//*************************************************************************
|
||||
bool empty() const
|
||||
{
|
||||
return (mbegin == mend);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns the size of the array.
|
||||
//*************************************************************************
|
||||
size_t size() const
|
||||
{
|
||||
return (mend - mbegin);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns the maximum possible size of the array.
|
||||
//*************************************************************************
|
||||
size_t max_size() const
|
||||
{
|
||||
return size();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assign from a view.
|
||||
//*************************************************************************
|
||||
const_array_view<T>& operator=(const const_array_view<T>& other)
|
||||
{
|
||||
mbegin = other.mbegin;
|
||||
mend = other.mend;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assign from iterators
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
void assign(TIterator begin_, TIterator end_)
|
||||
{
|
||||
mbegin = etl::addressof(*begin_);
|
||||
mend = etl::addressof(*begin_) + std::distance(begin_, end_);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assign from iterator and size.
|
||||
//*************************************************************************
|
||||
template <typename TIterator,
|
||||
typename TSize>
|
||||
void assign(TIterator begin_, TSize size_)
|
||||
{
|
||||
mbegin = etl::addressof(*begin_);
|
||||
mend = etl::addressof(*begin_) + size_;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const reference to the indexed value.
|
||||
//*************************************************************************
|
||||
const_reference operator[](size_t i) const
|
||||
{
|
||||
return mbegin[i];
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const reference to the indexed value.
|
||||
//*************************************************************************
|
||||
const_reference at(size_t i) const
|
||||
{
|
||||
ETL_ASSERT((mbegin != nullptr && mend != nullptr), ETL_ERROR(array_view_uninitialised));
|
||||
ETL_ASSERT(i < size(), ETL_ERROR(array_view_bounds));
|
||||
return mbegin[i];
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Swaps with another array_view.
|
||||
//*************************************************************************
|
||||
void swap(const_array_view& other)
|
||||
{
|
||||
std::swap(mbegin, other.mbegin);
|
||||
std::swap(mend, other.mend);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Shrinks the view by moving its start forward.
|
||||
//*************************************************************************
|
||||
void remove_prefix(size_type n)
|
||||
{
|
||||
mbegin += n;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Shrinks the view by moving its end backward.
|
||||
//*************************************************************************
|
||||
void remove_suffix(size_type n)
|
||||
{
|
||||
mend -= n;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality for array views.
|
||||
//*************************************************************************
|
||||
friend bool operator == (const const_array_view<T>& lhs, const const_array_view<T>& rhs)
|
||||
{
|
||||
return (lhs.size() == rhs.size()) &&
|
||||
std::equal(lhs.begin(), lhs.end(), rhs.begin());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Inequality for array views.
|
||||
//*************************************************************************
|
||||
friend bool operator != (const const_array_view<T>& lhs, const const_array_view<T>& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Less-than for array views.
|
||||
//*************************************************************************
|
||||
friend bool operator < (const const_array_view<T>& lhs, const const_array_view<T>& rhs)
|
||||
{
|
||||
return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Greater-than for array views.
|
||||
//*************************************************************************
|
||||
friend bool operator > (const const_array_view<T>& lhs, const const_array_view<T>& rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Less-than-equal for array views.
|
||||
//*************************************************************************
|
||||
friend bool operator <= (const const_array_view<T>& lhs, const const_array_view<T>& rhs)
|
||||
{
|
||||
return !(lhs > rhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Greater-than-equal for array views.
|
||||
//*************************************************************************
|
||||
friend bool operator >= (const const_array_view<T>& lhs, const const_array_view<T>& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const T* mbegin;
|
||||
const T* mend;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Hash function.
|
||||
//*************************************************************************
|
||||
@ -828,16 +499,6 @@ namespace etl
|
||||
reinterpret_cast<const uint8_t*>(&view[view.size()]));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct hash<etl::const_array_view<T> >
|
||||
{
|
||||
size_t operator()(const etl::const_array_view<T>& view) const
|
||||
{
|
||||
return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&view[0]),
|
||||
reinterpret_cast<const uint8_t*>(&view[view.size()]));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -850,15 +511,6 @@ void swap(etl::array_view<T>& lhs, etl::array_view<T>& rhs)
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Swaps the values.
|
||||
//*************************************************************************
|
||||
template <typename T>
|
||||
void swap(etl::const_array_view<T>& lhs, etl::const_array_view<T>& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
#endif
|
||||
|
||||
54
include/etl/profiles/clang_generic.h
Normal file
54
include/etl/profiles/clang_generic.h
Normal file
@ -0,0 +1,54 @@
|
||||
///\file
|
||||
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2017 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ETL_CLANG_GENERIC_INCLUDED
|
||||
#define ETL_CLANG_GENERIC_INCLUDED
|
||||
|
||||
//*****************************************************************************
|
||||
// GCC
|
||||
//*****************************************************************************
|
||||
|
||||
#define ETL_TARGET_DEVICE_GENERIC
|
||||
#define ETL_TARGET_OS_NONE
|
||||
#define ETL_COMPILER_CLANG
|
||||
#ifdef __cplusplus
|
||||
#define ETL_CPP11_SUPPORTED (__cplusplus >= 201103L)
|
||||
#define ETL_CPP14_SUPPORTED (__cplusplus >= 201402L)
|
||||
#define ETL_CPP17_SUPPORTED (__cplusplus >= 201703L)
|
||||
#else
|
||||
#define ETL_CPP11_SUPPORTED 0
|
||||
#define ETL_CPP14_SUPPORTED 0
|
||||
#define ETL_CPP17_SUPPORTED 0
|
||||
#endif
|
||||
#define ETL_NO_NULLPTR_SUPPORT !ETL_CPP11_SUPPORTED
|
||||
#define ETL_NO_LARGE_CHAR_SUPPORT !ETL_CPP11_SUPPORTED
|
||||
#define ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED ETL_CPP14_SUPPORTED
|
||||
|
||||
#endif
|
||||
@ -37,6 +37,8 @@ SOFTWARE.
|
||||
#include "gcc_linux_x86.h"
|
||||
#elif defined(PROFILE_GCC_WINDOWS_X86)
|
||||
#include "gcc_windows_x86.h"
|
||||
#elif defined(PROFILE_CLANG_GENERIC)
|
||||
#include "clang_generic.h"
|
||||
#elif defined(PROFILE_ARM_V5_GENERIC)
|
||||
#include "armv5.h"
|
||||
#elif defined(PROFILE_ARM_V6_GENERIC)
|
||||
|
||||
@ -39,7 +39,7 @@ SOFTWARE.
|
||||
|
||||
#define ETL_VERSION_MAJOR 14
|
||||
#define ETL_VERSION_MINOR 28
|
||||
#define ETL_VERSION_PATCH 2
|
||||
#define ETL_VERSION_PATCH 3
|
||||
|
||||
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) ETL_STRINGIFY(ETL_VERSION_MINOR) ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_W ETL_WIDE_STRING(ETL_CONCAT(ETL_CONCAT(ETL_VERSION_MAJOR, ETL_VERSION_MINOR), ETL_VERSION_PATCH))
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
===============================================================================
|
||||
14.28.3
|
||||
Removed redundant etl::const_array_view
|
||||
|
||||
===============================================================================
|
||||
14.28.2
|
||||
Various fixes.
|
||||
|
||||
@ -47,7 +47,7 @@ namespace
|
||||
typedef std::vector<int> StlVData;
|
||||
|
||||
typedef etl::array_view<int> View;
|
||||
typedef etl::const_array_view<int> CView;
|
||||
typedef etl::array_view<const int> CView;
|
||||
|
||||
EtlData etldata = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
StlData stldata = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user