mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 11:05:33 +08:00
Removed workarounds in metaclass system that were needed for GCC 4.9 and old MSVC.
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "blackmisc/aviation/aircraftsituationlist.h"
|
||||
#include "blackmisc/aviation/aircraftsituation.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
|
||||
#include <tuple>
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/metaclass.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "blackmisc/aviation/airportlist.h"
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/range.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "blackmisc/audio/voiceroom.h"
|
||||
#include "blackmisc/aviation/comsystem.h"
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/pq/physicalquantity.h"
|
||||
#include "blackmisc/pq/units.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "blackmisc/aviation/comsystem.h"
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/iterator.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/network/user.h"
|
||||
#include "blackmisc/predicates.h"
|
||||
#include "blackmisc/range.h"
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/icon.h"
|
||||
#include "blackmisc/metaclass.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
|
||||
#include <QMetaType>
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "flightplanlist.h"
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/iterator.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/predicates.h"
|
||||
#include "blackmisc/range.h"
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
#include "blackmisc/aviation/liverylist.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/predicates.h"
|
||||
#include "blackmisc/range.h"
|
||||
|
||||
|
||||
@@ -12,8 +12,11 @@
|
||||
#ifndef BLACKMISC_METACLASS_H
|
||||
#define BLACKMISC_METACLASS_H
|
||||
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/invoke.h"
|
||||
#include "blackmisc/integersequence.h"
|
||||
#include <type_traits>
|
||||
#include <functional>
|
||||
#include <QString>
|
||||
|
||||
/*!
|
||||
* \defgroup MetaClass Metaclass system
|
||||
@@ -21,6 +24,25 @@
|
||||
* members of value classes.
|
||||
*/
|
||||
|
||||
//! \cond PRIVATE
|
||||
|
||||
// Work around MinGW problem with combination of constexpr and extern template
|
||||
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||
#define BLACK_NO_EXPORT_CONSTEXPR constexpr inline __attribute__((gnu_inline))
|
||||
#else
|
||||
#define BLACK_NO_EXPORT_CONSTEXPR constexpr
|
||||
#endif
|
||||
|
||||
// MSVC, GCC, Clang all have non-standard extensions for skipping trailing
|
||||
// commas in variadic macros, but the MSVC extension differs from the others.
|
||||
#ifdef Q_CC_MSVC
|
||||
#define BLACK_TRAILING_VA_ARGS(...) ,__VA_ARGS__
|
||||
#else
|
||||
#define BLACK_TRAILING_VA_ARGS(...) ,##__VA_ARGS__
|
||||
#endif
|
||||
|
||||
//! \endcond
|
||||
|
||||
/*!
|
||||
* Macro to define a nested metaclass that describes the attributes of its
|
||||
* enclosing class. Use in the private section of the class.
|
||||
@@ -142,7 +164,7 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
//! Return name as QLatin1String.
|
||||
Q_DECL_CONSTEXPR auto latin1Name() const { return QLatin1String(m_name); }
|
||||
constexpr auto latin1Name() const { return QLatin1String(m_name); }
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -153,16 +175,16 @@ namespace BlackMisc
|
||||
struct CMetaMemberList
|
||||
{
|
||||
//! Tuple of CMetaMember.
|
||||
const Private::tuple<Members...> m_members;
|
||||
const std::tuple<Members...> m_members;
|
||||
|
||||
//! Number of members.
|
||||
static constexpr size_t c_size = sizeof...(Members);
|
||||
|
||||
//! Convenience method returning the member at index I.
|
||||
template <size_t I>
|
||||
constexpr auto at(std::integral_constant<size_t, I> = {}) const BLACK_TRAILING_RETURN(Private::get<I>(m_members))
|
||||
constexpr auto at(std::integral_constant<size_t, I> = {}) const
|
||||
{
|
||||
return Private::get<I>(m_members);
|
||||
return std::get<I>(m_members);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -203,7 +225,7 @@ namespace BlackMisc
|
||||
template <typename... Members>
|
||||
constexpr static CMetaMemberList<Members...> makeMetaMemberList(Members... members)
|
||||
{
|
||||
return { Private::tuple<Members...>(members...) };
|
||||
return { std::tuple<Members...>(members...) };
|
||||
}
|
||||
|
||||
//! Return a CMetaMethod of type deduced from the type of the member.
|
||||
@@ -256,7 +278,7 @@ namespace BlackMisc
|
||||
template <size_t I>
|
||||
using index = std::integral_constant<size_t, I>;
|
||||
|
||||
constexpr static auto members() BLACK_TRAILING_RETURN(MetaClass::getMemberList()) { return MetaClass::getMemberList(); }
|
||||
constexpr static auto members() { return MetaClass::getMemberList(); }
|
||||
};
|
||||
|
||||
namespace Private
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_METACLASSPRIVATE_H
|
||||
#define BLACKMISC_METACLASSPRIVATE_H
|
||||
|
||||
#include "integersequence.h"
|
||||
#include <type_traits>
|
||||
#include <functional>
|
||||
#include <QString>
|
||||
|
||||
//! \cond PRIVATE
|
||||
|
||||
// GCC 4.9 doesn't utilize constexpr in the standard library
|
||||
#if ! (defined(Q_CC_GNU) && __GNUC__ <= 4)
|
||||
#define BLACK_HAS_CONSTEXPR_STDLIB
|
||||
#endif
|
||||
|
||||
// Work around MinGW problem with combination of constexpr and extern template
|
||||
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||
#define BLACK_NO_EXPORT_CONSTEXPR constexpr inline __attribute__((gnu_inline))
|
||||
#else
|
||||
#define BLACK_NO_EXPORT_CONSTEXPR constexpr
|
||||
#endif
|
||||
|
||||
// MSVC, GCC, Clang all have non-standard extensions for skipping trailing
|
||||
// commas in variadic macros, but the MSVC extension differs from the others.
|
||||
#ifdef Q_CC_MSVC
|
||||
#define BLACK_TRAILING_VA_ARGS(...) ,__VA_ARGS__
|
||||
#else
|
||||
#define BLACK_TRAILING_VA_ARGS(...) ,##__VA_ARGS__
|
||||
#endif
|
||||
|
||||
// Work around MSVC constexpr bug
|
||||
// https://connect.microsoft.com/VisualStudio/feedback/details/2028721
|
||||
#ifdef Q_CC_MSVC
|
||||
#define BLACK_DECLTYPE_AUTO auto
|
||||
#define BLACK_TRAILING_RETURN(EXPR) -> decltype(EXPR)
|
||||
#else
|
||||
#define BLACK_DECLTYPE_AUTO decltype(auto)
|
||||
#define BLACK_TRAILING_RETURN(EXPR)
|
||||
#endif
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Private
|
||||
{
|
||||
#ifdef BLACK_HAS_CONSTEXPR_STDLIB
|
||||
using std::tuple;
|
||||
using std::tuple_size;
|
||||
using std::get;
|
||||
using std::make_tuple;
|
||||
#else // Own implementation of tuple, because the one in GCC 4.9 is not constexpr.
|
||||
template <size_t I, typename T>
|
||||
struct tuple_part
|
||||
{
|
||||
constexpr tuple_part() {}
|
||||
constexpr tuple_part(const T &element) : m_element(element) {}
|
||||
T m_element;
|
||||
};
|
||||
|
||||
template <typename... Ts>
|
||||
struct tuple_impl;
|
||||
template <typename... Ts, size_t... Is>
|
||||
struct tuple_impl<index_sequence<Is...>, Ts...> : public tuple_part<Is, Ts>...
|
||||
{
|
||||
constexpr tuple_impl() {}
|
||||
constexpr tuple_impl(const Ts &... vs) : tuple_part<Is, Ts>(vs)... {}
|
||||
};
|
||||
|
||||
template <typename... Ts>
|
||||
struct tuple : public tuple_impl<make_index_sequence<sizeof...(Ts)>, Ts...>
|
||||
{
|
||||
constexpr tuple() {}
|
||||
constexpr tuple(const Ts &... vs) : tuple_impl<make_index_sequence<sizeof...(Ts)>, Ts...>(vs...) {}
|
||||
constexpr static size_t c_size = sizeof...(Ts);
|
||||
};
|
||||
|
||||
template <size_t I, typename T>
|
||||
constexpr decltype(auto) get_impl(tuple_part<I, T> &part) { return (part.m_element); }
|
||||
template <size_t I, typename T>
|
||||
constexpr decltype(auto) get_impl(tuple_part<I, T> &&part) { return std::move(part.m_element); }
|
||||
template <size_t I, typename T>
|
||||
constexpr decltype(auto) get_impl(const tuple_part<I, T> &part) { return (part.m_element); }
|
||||
template <size_t I, typename T>
|
||||
constexpr decltype(auto) get_impl(const tuple_part<I, T> &&part) { return std::move(part.m_element); }
|
||||
|
||||
template <size_t I, typename T>
|
||||
constexpr decltype(auto) get(T &&tuple) { return get_impl<I>(std::forward<T>(tuple)); }
|
||||
|
||||
template <typename T>
|
||||
struct tuple_size : public std::integral_constant<size_t, T::c_size> {};
|
||||
|
||||
template <typename... Ts>
|
||||
constexpr auto make_tuple(Ts &&... vs) { return tuple<std::decay_t<Ts>...>(std::forward<Ts>(vs)...); }
|
||||
#endif // ! BLACK_HAS_CONSTEXPR_STDLIB
|
||||
}
|
||||
}
|
||||
|
||||
//! \endcond
|
||||
|
||||
#endif
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/icon.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QString>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
#include "blackmisc/network/serverlist.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include <tuple>
|
||||
|
||||
namespace BlackMisc
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "blackmisc/network/textmessagelist.h"
|
||||
#include "blackmisc/iterator.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/network/textmessage.h"
|
||||
#include "blackmisc/range.h"
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
#include "blackmisc/network/userlist.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
|
||||
#include <QString>
|
||||
#include <tuple>
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "blackmisc/dictionary.h"
|
||||
#include "blackmisc/memotable.h"
|
||||
#include "blackmisc/metaclass.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/orderable.h"
|
||||
#include "blackmisc/pixmap.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "distributorlist.h"
|
||||
#include "simulatorinfo.h"
|
||||
#include "aircraftmodel.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
|
||||
#include <tuple>
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "blackmisc/containerbase.h"
|
||||
#include "blackmisc/dictionary.h"
|
||||
#include "blackmisc/metaclass.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/simulation/distributorlist.h"
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/fscommon/vpilotmodelrule.h"
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/dictionary.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/propertyindexvariantmap.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "blackmisc/aviation/aircrafticaocode.h"
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/pq/constants.h"
|
||||
#include "blackmisc/verify.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "blackmisc/aviation/airlineicaocode.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/network/user.h"
|
||||
#include "blackmisc/predicates.h"
|
||||
#include "blackmisc/range.h"
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include "blackmisc/weather/metar.h"
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackmisc/metaclassprivate.h"
|
||||
#include "blackmisc/range.h"
|
||||
#include "blackmisc/weather/weatherdataplugininfo.h"
|
||||
#include "blackmisc/weather/weatherdataplugininfolist.h"
|
||||
|
||||
Reference in New Issue
Block a user