Fix etl::tuple template signature error in pair assignment operator (#1265)

* Fix etl::tuple template signature error in pair assignment operator

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update etl::tuple to explicitly use etl::pair or std::pair in assignment operator

* Added tests for etl::tuple assignment from pair

---------

Co-authored-by: Bryton Flecker <bflecker@swe.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
This commit is contained in:
Bryton Flecker 2026-01-21 22:30:20 -06:00 committed by GitHub
parent b82bf3b79d
commit f9dc1caa94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 73 additions and 13 deletions

View File

@ -1,5 +1,4 @@
Embedded Template Library (ETL)
-------------------------
# ![alt text](https://github.com/ETLCPP/etl/blob/master/images/etl64.png?raw=true) Embedded Template Library (ETL)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/jwellbelove/etl)
[![Release date](https://img.shields.io/github/release-date/jwellbelove/etl?color=%231182c3)](https://img.shields.io/github/release-date/jwellbelove/etl?color=%231182c3)
@ -10,7 +9,6 @@ Embedded Template Library (ETL)
![GitHub Repo stars](https://img.shields.io/github/stars/ETLCPP/etl?style=flat)
![CI](https://github.com/ETLCPP/etl/actions/workflows/msvc.yml/badge.svg?branch=master)
[![Build status](https://ci.appveyor.com/api/projects/status/b7jgecv7unqjw4u0/branch/master?svg=true)](https://ci.appveyor.com/project/jwellbelove/etl/branch/master)
![CI](https://github.com/ETLCPP/etl/actions/workflows/gcc-c++11.yml/badge.svg?branch=master)
![CI](https://github.com/ETLCPP/etl/actions/workflows/gcc-c++14.yml/badge.svg?branch=master)

View File

@ -559,9 +559,9 @@ namespace etl
//*********************************
/// Assign from lvalue pair tuple type.
//*********************************
template <typename U1, typename U2, size_t NTypes = number_of_types<THead, TTail...>, etl::enable_if_t<NTypes == 2U, int> = 0>
template <typename U1, typename U2, size_t NTypes = number_of_types<THead, TTail...>(), etl::enable_if_t<NTypes == 2U, int> = 0>
ETL_CONSTEXPR14
tuple& operator =(pair<U1, U2>& p)
tuple& operator =(ETL_OR_STD::pair<U1, U2>& p)
{
get_value() = p.first;
get_base().get_value() = p.second;
@ -572,9 +572,9 @@ namespace etl
//*********************************
/// Assign from const lvalue pair tuple type.
//*********************************
template <typename U1, typename U2, size_t NTypes = number_of_types<THead, TTail...>, etl::enable_if_t<NTypes == 2U, int> = 0>
template <typename U1, typename U2, size_t NTypes = number_of_types<THead, TTail...>(), etl::enable_if_t<NTypes == 2U, int> = 0>
ETL_CONSTEXPR14
tuple& operator =(const pair<U1, U2>& p)
tuple& operator =(const ETL_OR_STD::pair<U1, U2>& p)
{
get_value() = p.first;
get_base().get_value() = p.second;
@ -585,9 +585,9 @@ namespace etl
//*********************************
/// Assign from rvalue pair tuple type.
//*********************************
template <typename U1, typename U2, size_t NTypes = number_of_types<THead, TTail...>, etl::enable_if_t<NTypes == 2U, int> = 0>
template <typename U1, typename U2, size_t NTypes = number_of_types<THead, TTail...>(), etl::enable_if_t<NTypes == 2U, int> = 0>
ETL_CONSTEXPR14
tuple& operator =(pair<U1, U2>&& p)
tuple& operator =(ETL_OR_STD::pair<U1, U2>&& p)
{
get_value() = etl::forward<U1>(p.first);
get_base().get_value() = etl::forward<U2>(p.second);
@ -598,12 +598,12 @@ namespace etl
//*********************************
/// Assign from const rvalue pair tuple type.
//*********************************
template <typename U1, typename U2, size_t NTypes = number_of_types<THead, TTail...>, etl::enable_if_t<NTypes == 2U, int> = 0>
template <typename U1, typename U2, size_t NTypes = number_of_types<THead, TTail...>(), etl::enable_if_t<NTypes == 2U, int> = 0>
ETL_CONSTEXPR14
tuple& operator =(const pair<U1, U2>&& p)
tuple& operator =(const ETL_OR_STD::pair<U1, U2>&& p)
{
get_value() = etl::forward<U1>(p.first);
get_base().get_value() = etl::forward<U2>(p.second);
get_value() = p.first;
get_base().get_value() = p.second;
return *this;
}

View File

@ -756,5 +756,67 @@ namespace
CHECK_EQUAL(etl::get<2>(tp), s);
}
#endif
//*************************************************************************
TEST(test_assign_from_lvalue_pair)
{
ETL_OR_STD::pair<int, Data> p(1, Data("2"));
etl::tuple<int, Data> tp(0, Data(""));
tp = p;
int i = etl::get<0>(tp);
Data d = etl::get<1>(tp);
CHECK_EQUAL(1, i);
CHECK_EQUAL(std::string("2"), d.value);
}
//*************************************************************************
TEST(test_assign_from_const_lvalue_pair)
{
const ETL_OR_STD::pair<int, Data> p(1, Data("2"));
etl::tuple<int, Data> tp(0, Data(""));
tp = p;
int i = etl::get<0>(tp);
Data d = etl::get<1>(tp);
CHECK_EQUAL(1, i);
CHECK_EQUAL(std::string("2"), d.value);
}
//*************************************************************************
TEST(test_assign_from_rvalue_pair)
{
etl::tuple<int, Data> tp(0, Data(""));
tp = ETL_OR_STD::pair<int, Data>(1, Data("2"));
int i = etl::get<0>(tp);
Data d = etl::get<1>(tp);
CHECK_EQUAL(1, i);
CHECK_EQUAL(std::string("2"), d.value);
}
//*************************************************************************
TEST(test_assign_from_const_rvalue_pair)
{
const ETL_OR_STD::pair<int, Data> p(1, Data("2"));
etl::tuple<int, Data> tp(0, Data(""));
tp = static_cast<const ETL_OR_STD::pair<int, Data>&&>(p);
int i = etl::get<0>(tp);
Data d = etl::get<1>(tp);
CHECK_EQUAL(1, i);
CHECK_EQUAL(std::string("2"), d.value);
}
}
}