GCC compatibility changes

This commit is contained in:
John Wellbelove 2018-01-23 12:15:12 +00:00
parent 7fc874617d
commit 71b865ae6b
9 changed files with 61 additions and 40 deletions

View File

@ -1,5 +1,5 @@
name=Embedded Template Library
version=10.11.0
version=10.11.1
author= John Wellbelove <john.wellbelove@etlcpp.com>
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
sentence=A C++ template library tailored for embedded systems.

View File

@ -114,7 +114,7 @@ namespace etl
//*************************************************************************
/// Returns a reference to the first element.
//*************************************************************************
ETL_CONSTEXPR reference front()
reference front()
{
return *&ARRAY_[FRONT];
}
@ -130,7 +130,7 @@ namespace etl
//*************************************************************************
/// Returns a reference to the last element.
//*************************************************************************
ETL_CONSTEXPR reference back()
reference back()
{
return *&ARRAY_[BACK];
}
@ -146,7 +146,7 @@ namespace etl
//*************************************************************************
/// Returns a pointer to the first element of the internal storage.
//*************************************************************************
ETL_CONSTEXPR pointer data()
pointer data()
{
return &ARRAY_[BEGIN];
}
@ -162,7 +162,7 @@ namespace etl
//*************************************************************************
/// Returns an iterator to the beginning of the array.
//*************************************************************************
ETL_CONSTEXPR iterator begin()
iterator begin()
{
return &ARRAY_[BEGIN];
}
@ -186,7 +186,7 @@ namespace etl
//*************************************************************************
/// Returns an iterator to the end of the array.
//*************************************************************************
ETL_CONSTEXPR iterator end()
iterator end()
{
return &ARRAY_[END];
}
@ -210,7 +210,7 @@ namespace etl
//*************************************************************************
// Returns an reverse iterator to the reverse beginning of the array.
//*************************************************************************
ETL_CONSTEXPR reverse_iterator rbegin()
reverse_iterator rbegin()
{
return reverse_iterator(&ARRAY_[END]);
}
@ -234,7 +234,7 @@ namespace etl
//*************************************************************************
/// Returns a reverse iterator to the end of the array.
//*************************************************************************
ETL_CONSTEXPR reverse_iterator rend()
reverse_iterator rend()
{
return reverse_iterator(&ARRAY_[BEGIN]);
}
@ -274,7 +274,7 @@ namespace etl
//*************************************************************************
/// Returns a reference to the indexed value.
//*************************************************************************
ETL_CONSTEXPR reference operator[](size_t i)
reference operator[](size_t i)
{
return ARRAY_[i];
}
@ -290,7 +290,7 @@ namespace etl
//*************************************************************************
/// Returns a reference to the indexed value.
//*************************************************************************
ETL_CONSTEXPR reference at(size_t i)
reference at(size_t i)
{
ETL_ASSERT(i < SIZE, ETL_ERROR(etl::array_wrapper_bounds));
return ARRAY_[i];
@ -299,7 +299,7 @@ namespace etl
//*************************************************************************
/// Returns a const reference to the indexed value.
//*************************************************************************
ETL_CONSTEXPR const_reference at(size_t i) const
const_reference at(size_t i) const
{
ETL_ASSERT(i < SIZE, ETL_ERROR(etl::array_wrapper_bounds));
return ARRAY_[i];
@ -316,8 +316,9 @@ namespace etl
//*************************************************************************
/// Swaps the contents of arrays.
//*************************************************************************
template <typename T, T(&ARRAYOTHER)[SIZE_]>
void swap(etl::array_wrapper<T, SIZE_, ARRAYOTHER>& other)
template <typename U, U(&ARRAYOTHER)[SIZE_]>
typename etl::enable_if<etl::is_same<T, U>::value, void>::type
swap(etl::array_wrapper<U, SIZE_, ARRAYOTHER>& other)
{
for (size_t i = 0; i < SIZE; ++i)
{
@ -345,7 +346,7 @@ namespace etl
{
return !(lhs == rhs);
}
//*************************************************************************
/// Less-than for array wrapper.
//*************************************************************************

View File

@ -240,13 +240,13 @@ namespace etl
{
return std::reverse_iterator<const TValue*>(&data[0]);
}
//*****************************************************************************
/// Get the next iterator.
///\ingroup container
//*****************************************************************************
template<class TIterator>
ETL_CONSTEXPR TIterator next(TIterator iterator, ptrdiff_t n = 1)
TIterator next(TIterator iterator, ptrdiff_t n = 1)
{
std::advance(iterator, n);
return iterator;
@ -257,7 +257,7 @@ namespace etl
///\ingroup container
//*****************************************************************************
template<class TIterator>
ETL_CONSTEXPR TIterator prev(TIterator iterator, ptrdiff_t n = 1)
TIterator prev(TIterator iterator, ptrdiff_t n = 1)
{
std::advance(iterator, -n);
return iterator;
@ -295,11 +295,11 @@ namespace etl
char(&array_size(T(&array)[ARRAY_SIZE]))[ARRAY_SIZE];
}
#if ETL_CPP11_SUPPORTED
#define ETL_ARRAY_SIZE(a) (etl::size(a))
#else
//#if ETL_CPP11_SUPPORTED
// #define ETL_ARRAY_SIZE(a) (etl::size(a))
//#else
#define ETL_ARRAY_SIZE(a) sizeof(etl::array_size(a))
#endif
//#endif
#endif

View File

@ -40,6 +40,7 @@ SOFTWARE.
#include "etl_profile.h"
#if ETL_CPP11_SUPPORTED
#define ETL_CONSTEXPR constexpr
#else

View File

@ -40,8 +40,13 @@ SOFTWARE.
#define ETL_TARGET_DEVICE_GENERIC
#define ETL_TARGET_OS_NONE
#define ETL_COMPILER_GCC
#define ETL_CPP11_SUPPORTED (__cplusplus >= 201103L)
#define ETL_CPP14_SUPPORTED (__cplusplus >= 201402L)
#ifdef __cplusplus
#define ETL_CPP11_SUPPORTED (__cplusplus >= 201103L)
#define ETL_CPP14_SUPPORTED (__cplusplus >= 201402L)
#else
#define ETL_CPP11_SUPPORTED 0
#define ETL_CPP14_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

View File

@ -40,8 +40,13 @@ SOFTWARE.
#define ETL_TARGET_DEVICE_X86
#define ETL_TARGET_OS_LINUX
#define ETL_COMPILER_GCC
#define ETL_CPP11_SUPPORTED (__cplusplus >= 201103L)
#define ETL_CPP14_SUPPORTED (__cplusplus >= 201402L)
#ifdef __cplusplus
#define ETL_CPP11_SUPPORTED (__cplusplus >= 201103L)
#define ETL_CPP14_SUPPORTED (__cplusplus >= 201402L)
#else
#define ETL_CPP11_SUPPORTED 0
#define ETL_CPP14_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

View File

@ -40,8 +40,13 @@ SOFTWARE.
#define ETL_TARGET_DEVICE_X86
#define ETL_TARGET_OS_WINDOWS
#define ETL_COMPILER_GCC
#define ETL_CPP11_SUPPORTED (__cplusplus >= 201103L)
#define ETL_CPP14_SUPPORTED (__cplusplus >= 201402L)
#ifdef __cplusplus
#define ETL_CPP11_SUPPORTED (__cplusplus >= 201103L)
#define ETL_CPP14_SUPPORTED (__cplusplus >= 201402L)
#else
#define ETL_CPP11_SUPPORTED 0
#define ETL_CPP14_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

View File

@ -1,4 +1,8 @@
===============================================================================
10.11.1
GCC compatibility changes.
===============================================================================
10.11.0
Added ETL_CONSTEXPR macro and applied to various functions.
Allows C++11 and above compilers to set functions as constexpr.

View File

@ -84,7 +84,7 @@ namespace
//*************************************************************************
TEST(test_indexes)
{
CHECK_EQUAL(5, Data5::SIZE);
CHECK_EQUAL(5 , Data5::SIZE);
CHECK_EQUAL(Data5::SIZE, Data5::MAX_SIZE);
CHECK_EQUAL(0, Data5::FRONT);
CHECK_EQUAL(Data5::SIZE - 1, Data5::BACK);
@ -357,32 +357,32 @@ namespace
TEST(test_size)
{
Data5 aw5;
CHECK_EQUAL(5, aw5.SIZE);
CHECK_EQUAL(5, aw5.size());
CHECK_EQUAL(5 , aw5.SIZE);
CHECK_EQUAL(5U, aw5.size());
const Data5 caw5a;
CHECK_EQUAL(5, caw5a.SIZE);
CHECK_EQUAL(5, caw5a.size());
CHECK_EQUAL(5 , caw5a.SIZE);
CHECK_EQUAL(5U, caw5a.size());
CData5 caw5b;
CHECK_EQUAL(5, caw5b.SIZE);
CHECK_EQUAL(5, caw5b.size());
CHECK_EQUAL(5 , caw5b.SIZE);
CHECK_EQUAL(5U, caw5b.size());
}
//*************************************************************************
TEST(test_max_size)
{
Data5 aw5;
CHECK_EQUAL(5, aw5.MAX_SIZE);
CHECK_EQUAL(5, aw5.max_size());
CHECK_EQUAL(5 , aw5.MAX_SIZE);
CHECK_EQUAL(5U, aw5.max_size());
const Data5 caw5a;
CHECK_EQUAL(5, caw5a.MAX_SIZE);
CHECK_EQUAL(5, caw5a.max_size());
CHECK_EQUAL(5 , caw5a.MAX_SIZE);
CHECK_EQUAL(5U, caw5a.max_size());
CData5 caw5b;
CHECK_EQUAL(5, caw5b.MAX_SIZE);
CHECK_EQUAL(5, caw5b.max_size());
CHECK_EQUAL(5 , caw5b.MAX_SIZE);
CHECK_EQUAL(5U, caw5b.max_size());
}
//*************************************************************************