mirror of
https://github.com/ETLCPP/etl.git
synced 2026-11-09 14:49:53 +08:00
Fixes for Ubuntu 18
This commit is contained in:
parent
b9778190dc
commit
f5f93926c9
2
.github/workflows/gcc.yml
vendored
2
.github/workflows/gcc.yml
vendored
@ -1,7 +1,7 @@
|
||||
name: gcc
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
branches: [ master, development ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
|
||||
@ -566,7 +566,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
array(T...) -> array<typename etl::common_type<T...>::type, sizeof...(T)>;
|
||||
#endif
|
||||
@ -574,7 +574,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename T, typename... TValues>
|
||||
constexpr auto make_array(TValues&&... values) -> etl::array<T, sizeof...(TValues)>
|
||||
{
|
||||
|
||||
@ -1281,7 +1281,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename T, typename... Ts>
|
||||
circular_buffer(T, Ts...)
|
||||
->circular_buffer<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
|
||||
@ -1756,7 +1756,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
forward_list(T...) ->forward_list<typename etl::common_type_t<T...>, sizeof...(T)>;
|
||||
#endif
|
||||
@ -1764,7 +1764,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_forward_list(T... t) -> etl::forward_list<typename etl::common_type_t<T...>, sizeof...(T)>
|
||||
{
|
||||
|
||||
@ -2024,60 +2024,92 @@ namespace etl
|
||||
#endif
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
// primary template (used for zero types)
|
||||
template<class...>
|
||||
struct common_type {};
|
||||
//*********************************************
|
||||
// common_type
|
||||
// Based on the sample implementation detailed on
|
||||
// https://en.cppreference.com/w/cpp/types/common_type
|
||||
//*********************************************
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
//***********************************
|
||||
// Primary template
|
||||
template<typename...>
|
||||
struct common_type
|
||||
{
|
||||
};
|
||||
|
||||
//////// one type
|
||||
template <class T>
|
||||
struct common_type<T> : common_type<T, T> {};
|
||||
//***********************************
|
||||
// One type
|
||||
template <typename T>
|
||||
struct common_type<T> : common_type<T, T>
|
||||
{
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
template<class...>
|
||||
namespace private_common_type
|
||||
{
|
||||
template <typename...>
|
||||
using void_t = void;
|
||||
|
||||
template<class T1, class T2>
|
||||
using conditional_result_t = decltype(false ? std::declval<T1>() : std::declval<T2>());
|
||||
template <typename T1, typename T2>
|
||||
using conditional_result_t = decltype(false ? declval<T1>() : declval<T2>());
|
||||
|
||||
template<class, class, class = void>
|
||||
struct decay_conditional_result {};
|
||||
template<class T1, class T2>
|
||||
template <typename, typename, typename = void>
|
||||
struct decay_conditional_result
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct decay_conditional_result<T1, T2, void_t<conditional_result_t<T1, T2>>>
|
||||
: std::decay<conditional_result_t<T1, T2>> {};
|
||||
: etl::decay<conditional_result_t<T1, T2>>
|
||||
{
|
||||
};
|
||||
|
||||
template<class T1, class T2, class = void>
|
||||
struct common_type_2_impl : decay_conditional_result<const T1&, const T2&> {};
|
||||
template <typename T1, typename T2, typename = void>
|
||||
struct common_type_2_impl : decay_conditional_result<const T1&, const T2&>
|
||||
{
|
||||
};
|
||||
|
||||
// C++11 implementation:
|
||||
// template<class, class, class = void>
|
||||
// struct common_type_2_impl {};
|
||||
|
||||
template<class T1, class T2>
|
||||
template <typename T1, typename T2>
|
||||
struct common_type_2_impl<T1, T2, void_t<conditional_result_t<T1, T2>>>
|
||||
: decay_conditional_result<T1, T2> {};
|
||||
: decay_conditional_result<T1, T2>
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
//////// two types
|
||||
template<class T1, class T2>
|
||||
//***********************************
|
||||
// Two types
|
||||
template <typename T1, typename T2>
|
||||
struct common_type<T1, T2>
|
||||
: std::conditional<std::is_same<T1, typename std::decay<T1>::type>::value&&
|
||||
std::is_same<T2, typename std::decay<T2>::type>::value,
|
||||
detail::common_type_2_impl<T1, T2>,
|
||||
common_type<typename std::decay<T2>::type,
|
||||
typename std::decay<T2>::type>>::type{};
|
||||
: etl::conditional<etl::is_same<T1, typename etl::decay<T1>::type>::value&& etl::is_same<T2, typename etl::decay<T2>::type>::value,
|
||||
private_common_type::common_type_2_impl<T1, T2>,
|
||||
common_type<typename etl::decay<T2>::type,
|
||||
typename etl::decay<T2>::type>>::type
|
||||
{
|
||||
};
|
||||
|
||||
//////// 3+ types
|
||||
namespace detail {
|
||||
template<class AlwaysVoid, class T1, class T2, class...R>
|
||||
struct common_type_multi_impl {};
|
||||
template<class T1, class T2, class...R>
|
||||
struct common_type_multi_impl<void_t<typename common_type<T1, T2>::type>, T1, T2, R...>
|
||||
: common_type<typename common_type<T1, T2>::type, R...> {};
|
||||
//***********************************
|
||||
// Three or more types
|
||||
namespace private_common_type
|
||||
{
|
||||
template <typename AlwaysVoid, typename T1, typename T2, typename... TRest>
|
||||
struct common_type_multi_impl
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename... TRest>
|
||||
struct common_type_multi_impl<void_t<typename common_type<T1, T2>::type>, T1, T2, TRest...>
|
||||
: common_type<typename common_type<T1, T2>::type, TRest...>
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
template<class T1, class T2, class... R>
|
||||
struct common_type<T1, T2, R...>
|
||||
: detail::common_type_multi_impl<void, T1, T2, R...> {};
|
||||
template<typename T1, typename T2, typename... TRest>
|
||||
struct common_type<T1, T2, TRest...>
|
||||
: private_common_type::common_type_multi_impl<void, T1, T2, TRest...>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename... T>
|
||||
using common_type_t = typename common_type<T...>::type;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1422,12 +1422,23 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename T, typename... Ts>
|
||||
indirect_vector(T, Ts...)
|
||||
->indirect_vector<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_indirect_vector(T... t) -> etl::indirect_vector<typename etl::common_type_t<T...>, sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// A indirect_vector implementation that uses a fixed size buffer.
|
||||
/// The buffer is supplied on construction.
|
||||
|
||||
@ -2166,7 +2166,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
list(T...) -> list<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>;
|
||||
@ -2175,7 +2175,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_list(T... t) -> etl::list<typename etl::common_type_t<T...>, sizeof...(T)>
|
||||
{
|
||||
|
||||
@ -1339,7 +1339,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
vector(T...) -> vector<typename etl::common_type_t<T...>, sizeof...(T)>;
|
||||
#endif
|
||||
@ -1347,7 +1347,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_vector(T... t) -> etl::vector<typename etl::common_type_t<T...>, sizeof...(T)>
|
||||
{
|
||||
@ -1641,12 +1641,12 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
vector(T*...) -> vector<typename etl::common_type_t<T*...>, sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_vector(T*... t) -> etl::vector<typename etl::common_type_t<T*...>, sizeof...(T)>
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user