mirror of
https://github.com/ETLCPP/etl.git
synced 2026-10-28 18:07:10 +08:00
C++11 compatibility updates
This commit is contained in:
parent
192703be9f
commit
01f7cf2b17
@ -775,7 +775,7 @@ namespace etl
|
||||
using tuple_type = etl::nth_base_t<Index, tuple<TTypes...>>&&;
|
||||
|
||||
// Cast the tuple to the selected type and get the value.
|
||||
return etl::forward<etl::tuple_element_t<Index, etl::tuple<TTypes...>>>(static_cast<tuple_type&&>(t).get_value());
|
||||
return etl::move(static_cast<tuple_type>(t).get_value());
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -794,7 +794,7 @@ namespace etl
|
||||
using tuple_type = const etl::nth_base_t<Index, etl::tuple<TTypes...>>&&;
|
||||
|
||||
// Cast the tuple to the selected type and get the value.
|
||||
return etl::forward<etl::tuple_element_t<Index, etl::tuple<TTypes...>>>(static_cast<tuple_type&&>(t).get_value());
|
||||
return etl::move(static_cast<tuple_type>(t).get_value());
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -811,10 +811,10 @@ namespace etl
|
||||
ETL_STATIC_ASSERT((etl::is_one_of<T, TTypes...>::value), "etl::get<Type> - Tuple does not contain the specified type");
|
||||
|
||||
// Get the tuple base type that contains a T
|
||||
using tuple_type = etl::private_tuple::tuple_type_base_t<T, tuple<TTypes...>>;
|
||||
using tuple_type = etl::private_tuple::tuple_type_base_t<T, tuple<TTypes...>>&;
|
||||
|
||||
// Cast the tuple to the selected type and get the value.
|
||||
return static_cast<tuple_type&>(t).get_value();
|
||||
return static_cast<tuple_type>(t).get_value();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -831,10 +831,10 @@ namespace etl
|
||||
ETL_STATIC_ASSERT((etl::is_one_of<T, TTypes...>::value), "etl::get<Type> - Tuple does not contain the specified type");
|
||||
|
||||
// Get the tuple base type that contains a T
|
||||
using tuple_type = etl::private_tuple::tuple_type_base_t<T, tuple<TTypes...>>;
|
||||
using tuple_type = const etl::private_tuple::tuple_type_base_t<T, tuple<TTypes...>>&;
|
||||
|
||||
// Cast the tuple to the selected type and get the value.
|
||||
return static_cast<const tuple_type&>(t).get_value();
|
||||
return static_cast<tuple_type>(t).get_value();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -851,10 +851,10 @@ namespace etl
|
||||
ETL_STATIC_ASSERT((etl::is_one_of<T, TTypes...>::value), "etl::get<Type> - Tuple does not contain the specified type");
|
||||
|
||||
// Get the tuple base type that contains a T
|
||||
using tuple_type = etl::private_tuple::tuple_type_base_t<T, tuple<TTypes...>>;
|
||||
using tuple_type = etl::private_tuple::tuple_type_base_t<T, tuple<TTypes...>>&&;
|
||||
|
||||
// Cast the tuple to the selected type and get the value.
|
||||
return etl::forward<T&&>(static_cast<tuple_type&&>(t).get_value());
|
||||
return etl::move(static_cast<tuple_type>(t).get_value());
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -871,10 +871,10 @@ namespace etl
|
||||
ETL_STATIC_ASSERT((etl::is_one_of<T, TTypes...>::value), "etl::get<Type> - Tuple does not contain the specified type");
|
||||
|
||||
// Get the tuple base type that contains a T
|
||||
using tuple_type = etl::private_tuple::tuple_type_base_t<T, tuple<TTypes...>>;
|
||||
using tuple_type = const etl::private_tuple::tuple_type_base_t<T, tuple<TTypes...>>&&;
|
||||
|
||||
// Cast the tuple to the selected type and get the value.
|
||||
return etl::forward<T&&>(static_cast<const tuple_type&&>(t).get_value());
|
||||
return etl::move(static_cast<tuple_type>(t).get_value());
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
|
||||
@ -239,7 +239,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get)
|
||||
TEST(test_get_using_index_lvalue)
|
||||
{
|
||||
etl::tuple<Data, DataM> data(Data("1"), DataM("3"));
|
||||
const etl::tuple<Data, DataM> const_data(Data("2"), DataM("4"));
|
||||
@ -255,6 +255,57 @@ namespace
|
||||
CHECK_EQUAL(std::string("4"), d3.value);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_using_index_rvalue)
|
||||
{
|
||||
etl::tuple<Data, DataM> data(Data("1"), DataM("3"));
|
||||
const etl::tuple<Data, DataM> const_data(Data("2"), DataM("4"));
|
||||
|
||||
Data&& d0 = etl::get<0>(etl::move(data));
|
||||
const Data&& d1 = etl::get<0>(etl::move(const_data));
|
||||
DataM&& d2 = etl::move(etl::get<1>(etl::move(data)));
|
||||
const DataM&& d3 = etl::move(etl::get<1>(etl::move(const_data)));
|
||||
|
||||
CHECK_EQUAL(std::string("1"), d0.value);
|
||||
CHECK_EQUAL(std::string("2"), d1.value);
|
||||
CHECK_EQUAL(std::string("3"), d2.value);
|
||||
CHECK_EQUAL(std::string("4"), d3.value);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_using_type_lvalue)
|
||||
{
|
||||
etl::tuple<Data, DataM> data(Data("1"), DataM("3"));
|
||||
const etl::tuple<Data, DataM> const_data(Data("2"), DataM("4"));
|
||||
|
||||
Data d0 = etl::get<Data>(data);
|
||||
Data d1 = etl::get<Data>(const_data);
|
||||
DataM d2 = etl::move(etl::get<DataM>(data));
|
||||
DataM d3 = etl::move(etl::get<DataM>(const_data));
|
||||
|
||||
CHECK_EQUAL(std::string("1"), d0.value);
|
||||
CHECK_EQUAL(std::string("2"), d1.value);
|
||||
CHECK_EQUAL(std::string("3"), d2.value);
|
||||
CHECK_EQUAL(std::string("4"), d3.value);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_using_type_rvalue)
|
||||
{
|
||||
etl::tuple<Data, DataM> data(Data("1"), DataM("3"));
|
||||
const etl::tuple<Data, DataM> const_data(Data("2"), DataM("4"));
|
||||
|
||||
Data&& d0 = etl::get<Data>(etl::move(data));
|
||||
const Data&& d1 = etl::get<Data>(etl::move(const_data));
|
||||
DataM&& d2 = etl::move(etl::get<DataM>(etl::move(data)));
|
||||
const DataM&& d3 = etl::move(etl::get<DataM>(etl::move(const_data)));
|
||||
|
||||
CHECK_EQUAL(std::string("1"), d0.value);
|
||||
CHECK_EQUAL(std::string("2"), d1.value);
|
||||
CHECK_EQUAL(std::string("3"), d2.value);
|
||||
CHECK_EQUAL(std::string("4"), d3.value);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_construct_from_pair)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user