Moved definition of swap to utility

This commit is contained in:
John Wellbelove 2020-02-24 10:32:41 +01:00
parent df92610da2
commit e3f665d3b2
6 changed files with 41 additions and 36 deletions

View File

@ -74,39 +74,6 @@ namespace etl
//*****************************************************************************
namespace etl
{
// We can't have std::swap and etl::swap templates coexisting in the unit tests
// as the compiler will be unable to decide of which one to use, due to ADL.
#if defined(ETL_NO_STL) && !defined(ETL_IN_UNIT_TEST)
//***************************************************************************
// swap
#if ETL_CPP11_SUPPORTED
template <typename T>
void swap(T& a, T& b) ETL_NOEXCEPT
{
T temp(etl::move(a));
a = etl::move(b);
b = etl::move(temp);
}
#else
template <typename T>
void swap(T& a, T& b) ETL_NOEXCEPT
{
T temp(a);
a = b;
b = temp;
}
#endif
template< class T, size_t N >
void swap(T(&a)[N], T(&b)[N]) ETL_NOEXCEPT
{
for (size_t i = 0; i < N; ++i)
{
swap(a[i], b[i]);
}
}
#endif
#if defined(ETL_NO_STL)
//***************************************************************************
// iter_swap

View File

@ -65,6 +65,39 @@ namespace etl
}
#endif
// We can't have std::swap and etl::swap templates coexisting in the unit tests
// as the compiler will be unable to decide of which one to use, due to ADL.
#if defined(ETL_NO_STL) && !defined(ETL_IN_UNIT_TEST)
//***************************************************************************
// swap
#if ETL_CPP11_SUPPORTED
template <typename T>
void swap(T& a, T& b) ETL_NOEXCEPT
{
T temp(etl::move(a));
a = etl::move(b);
b = etl::move(temp);
}
#else
template <typename T>
void swap(T& a, T& b) ETL_NOEXCEPT
{
T temp(a);
a = b;
b = temp;
}
#endif
template< class T, size_t N >
void swap(T(&a)[N], T(&b)[N]) ETL_NOEXCEPT
{
for (size_t i = 0; i < N; ++i)
{
swap(a[i], b[i]);
}
}
#endif
//******************************************************************************
template <typename T1, typename T2>
struct pair

View File

@ -39,7 +39,7 @@ SOFTWARE.
#define ETL_VERSION_MAJOR 16
#define ETL_VERSION_MINOR 4
#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_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH)
#define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH)

View File

@ -1,6 +1,6 @@
{
"name": "Embedded Template Library",
"version": "16.4.2",
"version": "16.4.3",
"authors": {
"name": "John Wellbelove",
"email": "john.wellbelove@etlcpp.com"

View File

@ -1,5 +1,5 @@
name=Embedded Template Library
version=16.4.2
version=16.4.3
author= John Wellbelove <john.wellbelove@etlcpp.com>
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
license=MIT

View File

@ -1,3 +1,8 @@
===============================================================================
16.4.3
Rearranged where etl::swap is defined to fix issues with certain compilers
Fixed most warnings for CLang
===============================================================================
16.4.2
Fix etl::pair error and warning.