mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-15 08:26:04 +08:00
Re-enabled all variant unit tests
This commit is contained in:
parent
0bdd5943da
commit
de1a19775e
@ -135,6 +135,9 @@ namespace etl
|
||||
/// remove_reference
|
||||
template <typename T> struct remove_reference { typedef T type; };
|
||||
template <typename T> struct remove_reference<T&> { typedef T type; };
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
template <typename T> struct remove_reference<T&&> { typedef T type; };
|
||||
#endif
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
template <typename T>
|
||||
@ -504,6 +507,11 @@ namespace etl
|
||||
template <bool B, typename T, typename F> struct conditional { typedef T type; };
|
||||
template <typename T, typename F> struct conditional<false, T, F> { typedef F type; };
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
template <bool B, typename T, typename F>
|
||||
using conditional_t = typename conditional<B, T, F>::type;
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// make_signed
|
||||
template <typename T> struct make_signed { typedef T type; };
|
||||
@ -1223,6 +1231,11 @@ namespace etl
|
||||
template <bool B, typename T, typename F> struct conditional { typedef T type; };
|
||||
template <typename T, typename F> struct conditional<false, T, F> { typedef F type; };
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
template <bool B, typename T, typename F>
|
||||
using conditional_t = typename conditional<B, T, F>::type;
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// make_signed
|
||||
///\ingroup type_traits
|
||||
@ -1618,6 +1631,186 @@ namespace etl
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename T, typename T1, typename... TRest>
|
||||
inline constexpr bool are_all_same_v = are_all_same<T, T1, TRest...>::value;
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// conjunction
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
template <typename...>
|
||||
struct conjunction : public etl::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T1, typename... Tn>
|
||||
struct conjunction<T1, Tn...> : public etl::conditional_t<bool(T1::value), etl::conjunction<Tn...>, T1>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct conjunction<T> : public T
|
||||
{
|
||||
};
|
||||
#endif
|
||||
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename... T>
|
||||
inline constexpr bool conjunction_v = conjunction<T...>::value;
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// disjunction
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
template <typename...>
|
||||
struct disjunction : public etl::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T1, typename... Tn>
|
||||
struct disjunction<T1, Tn...> : public etl::conditional_t<bool(T1::value), T1, disjunction<Tn...>>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T1> struct disjunction<T1> : public T1
|
||||
{
|
||||
};
|
||||
#endif
|
||||
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename... T>
|
||||
inline constexpr bool disjunction_v = etl::disjunction<T...>::value;
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && ETL_USING_STL && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) && ((!defined(ARDUINO) && ETL_NOT_USING_STLPORT) || defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED))
|
||||
|
||||
//*********************************************
|
||||
// Use the STL's definitions.
|
||||
//*********************************************
|
||||
template<typename T1, typename T2>
|
||||
struct is_assignable : public std::is_assignable<T1, T2>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct is_lvalue_assignable : public etl::is_assignable<typename etl::add_lvalue_reference<T1>::type,
|
||||
typename etl::add_lvalue_reference<typename etl::add_const<T2>::type>::type>
|
||||
{
|
||||
};
|
||||
|
||||
template<typename T, typename... TArgs>
|
||||
struct is_constructible : public std::is_constructible<T, TArgs...>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_copy_constructible : public std::is_copy_constructible<T>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_move_constructible : public std::is_move_constructible<T>
|
||||
{
|
||||
};
|
||||
|
||||
//#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
|
||||
// template<typename T, typename... TArgs>
|
||||
// struct is_trivially_constructible : public std::is_trivially_constructible<T, TArgs...>
|
||||
// {
|
||||
// };
|
||||
//#endif
|
||||
|
||||
#elif defined(ETL_USE_TYPE_TRAITS_BUILTINS)
|
||||
|
||||
//*********************************************
|
||||
// Use the compiler's builtins.
|
||||
//*********************************************
|
||||
template<typename T1, typename T2>
|
||||
struct is_assignable : public bool_constant<__is_assignable(T1, T2)>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct is_lvalue_assignable : public etl::is_assignable<typename etl::add_lvalue_reference<T1>::type,
|
||||
typename etl::add_lvalue_reference<typename etl::add_const<T2>::type>::type>
|
||||
{
|
||||
};
|
||||
|
||||
template<typename T, typename... TArgs>
|
||||
struct is_constructible : public bool_constant<__is_constructible(T, TArgs...)>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_copy_constructible : public etl::is_constructible<T, etl::add_lvalue_reference_t<const T>>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_move_constructible : public etl::is_constructible<T, T>
|
||||
{
|
||||
};
|
||||
|
||||
//template<typename T, typename... TArgs>
|
||||
//struct is_trivially_constructible : public bool_constant<etl::is_constructible<T, Args...>::value&& __is_trivially_constructible(T, TArgs...)>
|
||||
//{
|
||||
//};
|
||||
|
||||
#else
|
||||
|
||||
//*********************************************
|
||||
// Force the user to provide specialisations.
|
||||
//*********************************************
|
||||
template<typename T, typename... TArgs>
|
||||
struct is_assignable : public etl::bool_constant<true>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct is_lvalue_assignable : public etl::bool_constant<true>
|
||||
{
|
||||
};
|
||||
|
||||
template<typename T, typename... TArgs>
|
||||
struct is_constructible : public etl::bool_constant<true>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_copy_constructible : public etl::bool_constant<etl::is_pod<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_move_constructible : public etl::bool_constant<etl::is_pod<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
//template<typename T, typename... TArgs>
|
||||
//struct is_trivially_constructible : public etl::bool_constant<etl::is_pod<T>::value>
|
||||
//{
|
||||
//};
|
||||
|
||||
#endif
|
||||
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template<typename T1, typename T2>
|
||||
inline constexpr size_t is_assignable_v = etl::is_assignable<T1, T2>::value;
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline constexpr size_t is_lvalue_assignable_v = etl::is_lvalue_assignable<T1, T2>::value;
|
||||
|
||||
template<typename T, typename... TArgs>
|
||||
inline constexpr size_t is_constructible_v = etl::is_constructible<T, TArgs...>::value;
|
||||
|
||||
template<typename T>
|
||||
inline constexpr size_t is_copy_constructible_v = etl::is_copy_constructible<T>::value;
|
||||
|
||||
template<typename T>
|
||||
inline constexpr size_t is_move_constructible_v = etl::is_move_constructible<T>::value;
|
||||
|
||||
//template<typename T, typename... TArgs>
|
||||
//inline constexpr size_t is_trivially_constructible_v = etl::is_trivially_constructible<T, TArgs...>::value;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,6 @@ SOFTWARE.
|
||||
|
||||
#include "../platform.h"
|
||||
#include "../utility.h"
|
||||
#include "../array.h"
|
||||
#include "../largest.h"
|
||||
#include "../exception.h"
|
||||
#include "../type_traits.h"
|
||||
@ -260,7 +259,7 @@ namespace etl
|
||||
|
||||
default_construct_in_place<type>(data);
|
||||
operation = operation_type<type, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
|
||||
type_id = 0U;
|
||||
type_id = 0U;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -269,15 +268,12 @@ namespace etl
|
||||
template <typename T, etl::enable_if_t<!etl::is_same<etl::remove_reference_t<T>, variant>::value, int> = 0>
|
||||
ETL_CONSTEXPR14 variant(T&& value)
|
||||
: data()
|
||||
, operation(operation_type<etl::remove_reference_t<T>, etl::is_copy_constructible<etl::remove_reference_t<T>>::value, etl::is_move_constructible<etl::remove_reference_t<T>>::value>::do_operation)
|
||||
, type_id(etl::private_variant::parameter_pack<TTypes...>::template index_of_type<etl::remove_reference_t<T>>::value)
|
||||
{
|
||||
using type = etl::remove_reference_t<T>;
|
||||
static_assert(etl::is_one_of<etl::remove_reference_t<T>, TTypes...>::value, "Unsupported type");
|
||||
|
||||
static_assert(etl::is_one_of<type, TTypes...>::value, "Unsupported type");
|
||||
|
||||
construct_in_place<type>(data, std::forward<T>(value));
|
||||
|
||||
operation = operation_type<T, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
|
||||
type_id = etl::private_variant::parameter_pack<TTypes...>::template index_of_type<type>::value;
|
||||
construct_in_place<etl::remove_reference_t<T>>(data, std::forward<T>(value));
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -286,13 +282,12 @@ namespace etl
|
||||
template <typename T, typename... TArgs>
|
||||
ETL_CONSTEXPR14 explicit variant(etl::in_place_type_t<T>, TArgs&&... args)
|
||||
: data()
|
||||
, operation(operation_type<etl::remove_reference_t<T>, etl::is_copy_constructible<etl::remove_reference_t<T>>::value, etl::is_move_constructible<etl::remove_reference_t<T>>::value>::do_operation)
|
||||
, type_id(etl::private_variant::parameter_pack<TTypes...>::template index_of_type<etl::remove_reference_t<T>>::value)
|
||||
{
|
||||
using type = etl::remove_reference_t<T>;
|
||||
static_assert(etl::is_one_of<etl::remove_reference_t<T>>, TTypes...>::value, "Unsupported type");
|
||||
|
||||
construct_in_place_args<type>(data, std::forward<TArgs>(args)...);
|
||||
|
||||
operation = operation_type<T, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
|
||||
type_id = etl::private_variant::parameter_pack<TTypes...>::template index_of_type<type>::value;
|
||||
construct_in_place_args<etl::remove_reference_t<T>>(data, std::forward<TArgs>(args)...);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -304,10 +299,11 @@ namespace etl
|
||||
, type_id(Index)
|
||||
{
|
||||
using type = typename private_variant::parameter_pack<TTypes...>:: template type_from_index_t<Index>;
|
||||
static_assert(etl::is_one_of<type>, TTypes... > ::value, "Unsupported type");
|
||||
|
||||
construct_in_place_args<type>(data, std::forward<TArgs>(args)...);
|
||||
|
||||
operation = operation_type<T, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
|
||||
operation = operation_type<type, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
@ -317,13 +313,12 @@ namespace etl
|
||||
template <typename T, typename U, typename... TArgs >
|
||||
ETL_CONSTEXPR14 explicit variant(etl::in_place_type_t<T>, std::initializer_list<U> init, TArgs&&... args)
|
||||
: data()
|
||||
, operation(operation_type<etl::remove_reference_t<T>>, etl::is_copy_constructible<etl::remove_reference_t<T>>::value, etl::is_move_constructible<type>::etl::remove_reference_t<T>>::do_operation)
|
||||
, type_id(private_variant::parameter_pack<TTypes...>:: template index_of_type<etl::remove_reference_t<T>>::value)
|
||||
{
|
||||
using type = etl::remove_reference_t<T>;
|
||||
static_assert(etl::is_one_of<etl::remove_reference_t<T>>, TTypes... > ::value, "Unsupported type");
|
||||
|
||||
construct_in_place_args<type>(data, std::forward<TArgs>(args)...);
|
||||
|
||||
operation = operation_type<T, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
|
||||
type_id = private_variant::parameter_pack<TTypes...>:: template index_of_type<type>::value;
|
||||
construct_in_place_args<etl::remove_reference_t<T>>(data, std::forward<TArgs>(args)...);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -335,10 +330,11 @@ namespace etl
|
||||
, type_id(Index)
|
||||
{
|
||||
using type = typename private_variant::parameter_pack<TTypes...>:: template type_from_index_t<Index>;
|
||||
static_assert(etl::is_one_of<type>, TTypes... > ::value, "Unsupported type");
|
||||
|
||||
construct_in_place_args<type>(data, std::forward<TArgs>(args)...);
|
||||
|
||||
operation = operation_type<T, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
|
||||
operation = operation_type<type, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -418,7 +414,7 @@ namespace etl
|
||||
|
||||
construct_in_place_args<type>(data, std::forward<TArgs>(args)...);
|
||||
|
||||
operation = operation_type<T, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
|
||||
operation = operation_type<type, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
|
||||
|
||||
type_id = etl::private_variant::parameter_pack<TTypes...>::template index_of_type<T>::value;
|
||||
|
||||
@ -440,7 +436,7 @@ namespace etl
|
||||
|
||||
construct_in_place<type>(data, etl::forward<T>(value));
|
||||
|
||||
operation = operation_type<T, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
|
||||
operation = operation_type<type, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
|
||||
type_id = etl::private_variant::parameter_pack<TTypes...>::template index_of_type<type>::value;
|
||||
|
||||
return *this;
|
||||
@ -520,9 +516,9 @@ namespace etl
|
||||
//***************************************************************************
|
||||
void swap(variant& rhs) noexcept
|
||||
{
|
||||
variant temp(*this);
|
||||
*this = rhs;
|
||||
rhs = temp;
|
||||
variant temp(etl::move(*this));
|
||||
*this = etl::move(rhs);
|
||||
rhs = etl::move(temp);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -585,9 +581,7 @@ namespace etl
|
||||
{
|
||||
using type = etl::remove_reference_t<T>;
|
||||
|
||||
type t;
|
||||
|
||||
::new (pstorage) type(etl::forward<type>(args)...);
|
||||
::new (pstorage) type(etl::forward<TArgs>(args)...);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -596,7 +590,9 @@ namespace etl
|
||||
template <typename T>
|
||||
static void default_construct_in_place(char* pstorage)
|
||||
{
|
||||
::new (pstorage) T();
|
||||
using type = etl::remove_reference_t<T>;
|
||||
|
||||
::new (pstorage) type();
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
@ -612,31 +608,33 @@ namespace etl
|
||||
static void do_operation(variant::command operation, char* pstorage, const char* pvalue)
|
||||
{
|
||||
// This should never occur.
|
||||
#if defined(ETL_IN_UNIT_TEST)
|
||||
assert(false);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
//*******************************************
|
||||
// Specialisation for no-copyable & non-moveable
|
||||
// Specialisation for no-copyable & non-moveable types.
|
||||
template <typename T>
|
||||
struct operation_type<T, false, false>
|
||||
{
|
||||
static void do_operation(variant::command operation, char* pstorage, const char* pvalue)
|
||||
{
|
||||
using type = etl::remove_reference_t<T>;
|
||||
|
||||
switch (operation)
|
||||
{
|
||||
case variant::command::Destroy:
|
||||
{
|
||||
reinterpret_cast<const type*>(pstorage)->~type();
|
||||
reinterpret_cast<const T*>(pstorage)->~T();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
// This should never occur.
|
||||
#if defined(ETL_IN_UNIT_TEST)
|
||||
assert(false);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -644,32 +642,32 @@ namespace etl
|
||||
};
|
||||
|
||||
//*******************************************
|
||||
// Specialisation for no-copyable & moveable
|
||||
// Specialisation for no-copyable & moveable types.
|
||||
template <typename T>
|
||||
struct operation_type<T, false, true>
|
||||
{
|
||||
static void do_operation(variant::command operation, char* pstorage, const char* pvalue)
|
||||
{
|
||||
using type = etl::remove_reference_t<T>;
|
||||
|
||||
switch (operation)
|
||||
{
|
||||
case variant::command::Move:
|
||||
{
|
||||
::new (pstorage) type(etl::move(*reinterpret_cast<type*>(const_cast<char*>(pvalue))));
|
||||
::new (pstorage) T(etl::move(*reinterpret_cast<T*>(const_cast<char*>(pvalue))));
|
||||
break;
|
||||
}
|
||||
|
||||
case variant::command::Destroy:
|
||||
{
|
||||
reinterpret_cast<const type*>(pstorage)->~type();
|
||||
reinterpret_cast<const T*>(pstorage)->~T();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
// This should never occur.
|
||||
#if defined(ETL_IN_UNIT_TEST)
|
||||
assert(false);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -677,32 +675,32 @@ namespace etl
|
||||
};
|
||||
|
||||
//*******************************************
|
||||
// Specialisation for copyable & non-moveable
|
||||
// Specialisation for copyable & non-moveable types.
|
||||
template <typename T>
|
||||
struct operation_type<T, true, false>
|
||||
{
|
||||
static void do_operation(variant::command operation, char* pstorage, const char* pvalue)
|
||||
{
|
||||
using type = etl::remove_reference_t<T>;
|
||||
|
||||
switch (operation)
|
||||
{
|
||||
case variant::command::Copy:
|
||||
{
|
||||
::new (pstorage) type(*reinterpret_cast<const type*>(pvalue));
|
||||
::new (pstorage) T(*reinterpret_cast<const T*>(pvalue));
|
||||
break;
|
||||
}
|
||||
|
||||
case variant::command::Destroy:
|
||||
{
|
||||
reinterpret_cast<const type*>(pstorage)->~type();
|
||||
reinterpret_cast<const T*>(pstorage)->~T();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
// This should never occur.
|
||||
#if defined(ETL_IN_UNIT_TEST)
|
||||
assert(false);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -710,31 +708,29 @@ namespace etl
|
||||
};
|
||||
|
||||
//*******************************************
|
||||
// Specialisation for copyable & moveable
|
||||
// Specialisation for copyable & moveable types.
|
||||
template <typename T>
|
||||
struct operation_type<T, true, true>
|
||||
{
|
||||
static void do_operation(variant::command command, char* pstorage, const char* pvalue)
|
||||
{
|
||||
using type = etl::remove_reference_t<T>;
|
||||
|
||||
switch (command)
|
||||
{
|
||||
case variant::command::Copy:
|
||||
{
|
||||
::new (pstorage) type(*reinterpret_cast<const type*>(pvalue));
|
||||
::new (pstorage) T(*reinterpret_cast<const T*>(pvalue));
|
||||
break;
|
||||
}
|
||||
|
||||
case variant::command::Move:
|
||||
{
|
||||
::new (pstorage) type(etl::move(*reinterpret_cast<type*>(const_cast<char*>(pvalue))));
|
||||
::new (pstorage) T(etl::move(*reinterpret_cast<T*>(const_cast<char*>(pvalue))));
|
||||
break;
|
||||
}
|
||||
|
||||
case variant::command::Destroy:
|
||||
{
|
||||
reinterpret_cast<const type*>(pstorage)->~type();
|
||||
reinterpret_cast<const T*>(pstorage)->~T();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -938,6 +934,24 @@ namespace etl
|
||||
return (Index == variant_npos) ? false : (v.index() == Index);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Checks if the variant v holds the alternative Index.
|
||||
//***************************************************************************
|
||||
template <size_t Index, typename... TTypes>
|
||||
ETL_CONSTEXPR14 bool holds_alternative(const etl::variant<TTypes...>& v) noexcept
|
||||
{
|
||||
return (Index == v.index());
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Checks if the variant v holds the alternative Index. (Runtime)
|
||||
//***************************************************************************
|
||||
template <typename... TTypes>
|
||||
ETL_CONSTEXPR14 bool holds_alternative(size_t index, const etl::variant<TTypes...>& v) noexcept
|
||||
{
|
||||
return (index == v.index());
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// variant_alternative
|
||||
//***************************************************************************
|
||||
|
||||
@ -123,6 +123,9 @@ namespace etl
|
||||
/// remove_reference
|
||||
template <typename T> struct remove_reference { typedef T type; };
|
||||
template <typename T> struct remove_reference<T&> { typedef T type; };
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
template <typename T> struct remove_reference<T&&> { typedef T type; };
|
||||
#endif
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
template <typename T>
|
||||
@ -1669,6 +1672,140 @@ namespace etl
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename... T>
|
||||
inline constexpr bool disjunction_v = etl::disjunction<T...>::value;
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && ETL_USING_STL && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) && ((!defined(ARDUINO) && ETL_NOT_USING_STLPORT) || defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED))
|
||||
|
||||
//*********************************************
|
||||
// Use the STL's definitions.
|
||||
//*********************************************
|
||||
template<typename T1, typename T2>
|
||||
struct is_assignable : public std::is_assignable<T1, T2>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct is_lvalue_assignable : public etl::is_assignable<typename etl::add_lvalue_reference<T1>::type,
|
||||
typename etl::add_lvalue_reference<typename etl::add_const<T2>::type>::type>
|
||||
{
|
||||
};
|
||||
|
||||
template<typename T, typename... TArgs>
|
||||
struct is_constructible : public std::is_constructible<T, TArgs...>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_copy_constructible : public std::is_copy_constructible<T>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_move_constructible : public std::is_move_constructible<T>
|
||||
{
|
||||
};
|
||||
|
||||
//#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
|
||||
// template<typename T, typename... TArgs>
|
||||
// struct is_trivially_constructible : public std::is_trivially_constructible<T, TArgs...>
|
||||
// {
|
||||
// };
|
||||
//#endif
|
||||
|
||||
#elif defined(ETL_USE_TYPE_TRAITS_BUILTINS)
|
||||
|
||||
//*********************************************
|
||||
// Use the compiler's builtins.
|
||||
//*********************************************
|
||||
template<typename T1, typename T2>
|
||||
struct is_assignable : public bool_constant<__is_assignable(T1, T2)>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct is_lvalue_assignable : public etl::is_assignable<typename etl::add_lvalue_reference<T1>::type,
|
||||
typename etl::add_lvalue_reference<typename etl::add_const<T2>::type>::type>
|
||||
{
|
||||
};
|
||||
|
||||
template<typename T, typename... TArgs>
|
||||
struct is_constructible : public bool_constant<__is_constructible(T, TArgs...)>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_copy_constructible : public etl::is_constructible<T, etl::add_lvalue_reference_t<const T>>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_move_constructible : public etl::is_constructible<T, T>
|
||||
{
|
||||
};
|
||||
|
||||
//template<typename T, typename... TArgs>
|
||||
//struct is_trivially_constructible : public bool_constant<etl::is_constructible<T, Args...>::value&& __is_trivially_constructible(T, TArgs...)>
|
||||
//{
|
||||
//};
|
||||
|
||||
#else
|
||||
|
||||
//*********************************************
|
||||
// Force the user to provide specialisations.
|
||||
//*********************************************
|
||||
template<typename T, typename... TArgs>
|
||||
struct is_assignable : public etl::bool_constant<true>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct is_lvalue_assignable : public etl::bool_constant<true>
|
||||
{
|
||||
};
|
||||
|
||||
template<typename T, typename... TArgs>
|
||||
struct is_constructible : public etl::bool_constant<true>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_copy_constructible : public etl::bool_constant<etl::is_pod<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_move_constructible : public etl::bool_constant<etl::is_pod<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
//template<typename T, typename... TArgs>
|
||||
//struct is_trivially_constructible : public etl::bool_constant<etl::is_pod<T>::value>
|
||||
//{
|
||||
//};
|
||||
|
||||
#endif
|
||||
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline constexpr size_t is_assignable_v = etl::is_assignable<T1, T2>::value;
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline constexpr size_t is_lvalue_assignable_v = etl::is_lvalue_assignable<T1, T2>::value;
|
||||
|
||||
template<typename T, typename... TArgs>
|
||||
inline constexpr size_t is_constructible_v = etl::is_constructible<T, TArgs...>::value;
|
||||
|
||||
template<typename T>
|
||||
inline constexpr size_t is_copy_constructible_v = etl::is_copy_constructible<T>::value;
|
||||
|
||||
template<typename T>
|
||||
inline constexpr size_t is_move_constructible_v = etl::is_move_constructible<T>::value;
|
||||
|
||||
//template<typename T, typename... TArgs>
|
||||
//inline constexpr size_t is_trivially_constructible_v = etl::is_trivially_constructible<T, TArgs...>::value;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -80,6 +80,8 @@ SOFTWARE.
|
||||
|
||||
//#define ETL_NO_STL
|
||||
|
||||
#define ETL_USE_TYPE_TRAITS_BUILTINS
|
||||
|
||||
#if defined(ETL_FORCE_TEST_CPP03)
|
||||
#define ETL_FUNCTION_FORCE_CPP03
|
||||
#define ETL_PRIORITY_QUEUE_FORCE_CPP03
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user