mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Fixed const&& move constructors
# Conflicts: # include/etl/tuple.h
This commit is contained in:
parent
e2f2a39a97
commit
ccb37a12a3
@ -361,8 +361,8 @@ namespace etl
|
||||
etl::is_convertible<UHead, THead>::value, int> = 0>
|
||||
ETL_CONSTEXPR14
|
||||
tuple(const tuple<UHead, UTail...>&& other)
|
||||
: base_type(etl::forward<tuple<UTail...>>(other.get_base()))
|
||||
, value(etl::forward<UHead>(other.get_value()))
|
||||
: base_type(other.get_base())
|
||||
, value(other.get_value())
|
||||
{
|
||||
}
|
||||
|
||||
@ -375,8 +375,8 @@ namespace etl
|
||||
!etl::is_convertible<UHead, THead>::value, int> = 0>
|
||||
ETL_CONSTEXPR14
|
||||
explicit tuple(const tuple<UHead, UTail...>&& other)
|
||||
: base_type(etl::forward<tuple<UTail...>>(other.get_base()))
|
||||
, value(etl::forward<UHead>(other.get_value()))
|
||||
: base_type(other.get_base())
|
||||
, value(other.get_value())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -48,6 +48,33 @@ namespace
|
||||
return std::array<std::size_t, sizeof...(Indices)>{Indices...};
|
||||
}
|
||||
|
||||
//*********************************
|
||||
struct From
|
||||
{
|
||||
From(int i_)
|
||||
: i(i_)
|
||||
{
|
||||
}
|
||||
|
||||
int i;
|
||||
};
|
||||
|
||||
//*********************************
|
||||
struct To
|
||||
{
|
||||
explicit To(const From& from)
|
||||
: i(from.i)
|
||||
{
|
||||
}
|
||||
|
||||
To& operator =(const From& from)
|
||||
{
|
||||
i = from.i;
|
||||
}
|
||||
|
||||
int i;
|
||||
};
|
||||
|
||||
SUITE(test_tuple)
|
||||
{
|
||||
//*************************************************************************
|
||||
@ -103,8 +130,97 @@ namespace
|
||||
//*************************************************************************
|
||||
TEST(test_copy_constructor)
|
||||
{
|
||||
etl::tuple<int, double, int, Data> tp;
|
||||
etl::tuple<int, double, int, Data> tp(1, 2.2, 3, Data("4"));
|
||||
etl::tuple<int, double, int, Data> otherTuple(tp);
|
||||
|
||||
CHECK_EQUAL(etl::get<0>(tp), etl::get<0>(otherTuple));
|
||||
CHECK_EQUAL(etl::get<1>(tp), etl::get<1>(otherTuple));
|
||||
CHECK_EQUAL(etl::get<2>(tp), etl::get<2>(otherTuple));
|
||||
CHECK_EQUAL(etl::get<3>(tp), etl::get<3>(otherTuple));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_copy_constructor_from_explicitly_convertible_type)
|
||||
{
|
||||
etl::tuple<From> from(1);
|
||||
etl::tuple<To> to(from);
|
||||
|
||||
CHECK_EQUAL(etl::get<0>(to).i, etl::get<0>(from).i);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_copy_constructor_from_const_explicitly_convertible_type)
|
||||
{
|
||||
const etl::tuple<From> from(1);
|
||||
etl::tuple<To> to(from);
|
||||
|
||||
CHECK_EQUAL(etl::get<0>(to).i, etl::get<0>(from).i);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_move_constructor)
|
||||
{
|
||||
etl::tuple<int, double, int, Data> tp(1, 2.2, 3, Data("4"));
|
||||
etl::tuple<int, double, int, Data> otherTuple(etl::move(tp));
|
||||
|
||||
CHECK_EQUAL(etl::get<0>(tp), etl::get<0>(otherTuple));
|
||||
CHECK_EQUAL(etl::get<1>(tp), etl::get<1>(otherTuple));
|
||||
CHECK_EQUAL(etl::get<2>(tp), etl::get<2>(otherTuple));
|
||||
CHECK_EQUAL(etl::get<3>(tp), etl::get<3>(otherTuple));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_move_constructor_from_const)
|
||||
{
|
||||
const etl::tuple<int, double, int, Data> tp(1, 2.2, 3, Data("4"));
|
||||
etl::tuple<int, double, int, Data> otherTuple(etl::move(tp));
|
||||
|
||||
CHECK_EQUAL(etl::get<0>(tp), etl::get<0>(otherTuple));
|
||||
CHECK_EQUAL(etl::get<1>(tp), etl::get<1>(otherTuple));
|
||||
CHECK_EQUAL(etl::get<2>(tp), etl::get<2>(otherTuple));
|
||||
CHECK_EQUAL(etl::get<3>(tp), etl::get<3>(otherTuple));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_move_constructor_from_implicitly_convertible_type)
|
||||
{
|
||||
etl::tuple<short, float, short, Data> tp(1, 2.2f, 3, Data("4"));
|
||||
etl::tuple<int, double, int, Data> otherTuple(etl::move(tp));
|
||||
|
||||
CHECK_EQUAL(etl::get<0>(tp), etl::get<0>(otherTuple));
|
||||
CHECK_EQUAL(etl::get<1>(tp), etl::get<1>(otherTuple));
|
||||
CHECK_EQUAL(etl::get<2>(tp), etl::get<2>(otherTuple));
|
||||
CHECK_EQUAL(etl::get<3>(tp), etl::get<3>(otherTuple));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_move_constructor_from_const_implicitly_convertible_type)
|
||||
{
|
||||
const etl::tuple<short, float, short, Data> tp(1, 2.2f, 3, Data("4"));
|
||||
etl::tuple<int, double, int, Data> otherTuple(etl::move(tp));
|
||||
|
||||
CHECK_EQUAL(etl::get<0>(tp), etl::get<0>(otherTuple));
|
||||
CHECK_EQUAL(etl::get<1>(tp), etl::get<1>(otherTuple));
|
||||
CHECK_EQUAL(etl::get<2>(tp), etl::get<2>(otherTuple));
|
||||
CHECK_EQUAL(etl::get<3>(tp), etl::get<3>(otherTuple));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_move_constructor_from_explicitly_convertible_type)
|
||||
{
|
||||
etl::tuple<From> from(1);
|
||||
etl::tuple<To> to(etl::move(from));
|
||||
|
||||
CHECK_EQUAL(etl::get<0>(to).i, etl::get<0>(from).i);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_move_constructor_from_const_explicitly_convertible_type)
|
||||
{
|
||||
const etl::tuple<From> from(1);
|
||||
etl::tuple<To> to(etl::move(from));
|
||||
|
||||
CHECK_EQUAL(etl::get<0>(to).i, etl::get<0>(from).i);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -112,6 +228,8 @@ namespace
|
||||
{
|
||||
etl::tuple<int> tp(1);
|
||||
etl::tuple<int> otherTuple(tp);
|
||||
|
||||
CHECK_EQUAL(etl::get<0>(tp), etl::get<0>(otherTuple));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user