mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-12-19 01:19:41 +08:00
Simplify traits.h using C++17
This patch simplifies gdbsupport/traits.h by reusing some C++17 type traits. I kept the local names, since they are generally better. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31423 Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
@@ -89,54 +89,17 @@ template<typename To, template<typename...> class Op, typename... Args>
|
||||
using is_detected_convertible
|
||||
= std::is_convertible<detected_t<Op, Args...>, To>;
|
||||
|
||||
/* A few trait helpers, mainly stolen from libstdc++. Uppercase
|
||||
because "and/or", etc. are reserved keywords. */
|
||||
/* A few trait helpers -- standard traits but with slightly nicer
|
||||
names. Uppercase because "and/or", etc. are reserved keywords. */
|
||||
|
||||
template<typename Predicate>
|
||||
struct Not : public std::integral_constant<bool, !Predicate::value>
|
||||
{};
|
||||
using Not = std::negation<Predicate>;
|
||||
|
||||
template<typename...>
|
||||
struct Or;
|
||||
template<typename ...T>
|
||||
using Or = std::disjunction<T...>;
|
||||
|
||||
template<>
|
||||
struct Or<> : public std::false_type
|
||||
{};
|
||||
|
||||
template<typename B1>
|
||||
struct Or<B1> : public B1
|
||||
{};
|
||||
|
||||
template<typename B1, typename B2>
|
||||
struct Or<B1, B2>
|
||||
: public std::conditional<B1::value, B1, B2>::type
|
||||
{};
|
||||
|
||||
template<typename B1,typename B2,typename B3, typename... Bn>
|
||||
struct Or<B1, B2, B3, Bn...>
|
||||
: public std::conditional<B1::value, B1, Or<B2, B3, Bn...>>::type
|
||||
{};
|
||||
|
||||
template<typename...>
|
||||
struct And;
|
||||
|
||||
template<>
|
||||
struct And<> : public std::true_type
|
||||
{};
|
||||
|
||||
template<typename B1>
|
||||
struct And<B1> : public B1
|
||||
{};
|
||||
|
||||
template<typename B1, typename B2>
|
||||
struct And<B1, B2>
|
||||
: public std::conditional<B1::value, B2, B1>::type
|
||||
{};
|
||||
|
||||
template<typename B1, typename B2, typename B3, typename... Bn>
|
||||
struct And<B1, B2, B3, Bn...>
|
||||
: public std::conditional<B1::value, And<B2, B3, Bn...>, B1>::type
|
||||
{};
|
||||
template<typename ...T>
|
||||
using And = std::conjunction<T...>;
|
||||
|
||||
/* Concepts-light-like helper to make SFINAE logic easier to read. */
|
||||
template<typename Condition>
|
||||
|
||||
Reference in New Issue
Block a user