mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 13:17:00 -04:00
CMake file
Update to C++ 11: std::shared_ptr, for each loops Update to wxWidgets 3.0+
This commit is contained in:
+20
-74
@@ -18,77 +18,19 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Typeof magic
|
||||
|
||||
#ifdef __GNUC__
|
||||
// GCC has a buildin typeof function, so it doesn't need (as much) hacks
|
||||
#define DECLARE_TYPEOF(T)
|
||||
#define DECLARE_TYPEOF_NO_REV(T)
|
||||
#define DECLARE_TYPEOF_CONST(T)
|
||||
#define DECLARE_TYPEOF_COLLECTION(T)
|
||||
|
||||
#define TYPEOF(Value) __typeof(Value)
|
||||
#define TYPEOF_IT(Value) __typeof((Value).begin())
|
||||
#define TYPEOF_CIT(Value) __typeof((Value).begin())
|
||||
#define TYPEOF_RIT(Value) __typeof((Value).rbegin())
|
||||
#define TYPEOF_CRIT(Value) __typeof((Value).rbegin())
|
||||
#define TYPEOF_REF(Value) __typeof(*(Value).begin())&
|
||||
#define TYPEOF_CREF(Value) __typeof(*(Value).begin())&
|
||||
|
||||
#else
|
||||
/// Helper for typeof tricks
|
||||
template<const type_info &ref_type_info> struct TypeOf {};
|
||||
// GCC has a buildin typeof function, so it doesn't need (as much) hacks
|
||||
#define DECLARE_TYPEOF(T)
|
||||
#define DECLARE_TYPEOF_NO_REV(T)
|
||||
#define DECLARE_TYPEOF_CONST(T)
|
||||
#define DECLARE_TYPEOF_COLLECTION(T)
|
||||
|
||||
/// The type of a value
|
||||
#define TYPEOF(Value) TypeOf<typeid(Value)>::type
|
||||
/// The type of an iterator
|
||||
#define TYPEOF_IT(Value) TypeOf<typeid(Value)>::iterator
|
||||
/// The type of a const iterator
|
||||
#define TYPEOF_CIT(Value) TypeOf<typeid(Value)>::const_iterator
|
||||
/// The type of a reverse iterator
|
||||
#define TYPEOF_RIT(Value) TypeOf<typeid(Value)>::reverse_iterator
|
||||
/// The type of a const reverse iterator
|
||||
#define TYPEOF_CRIT(Value) TypeOf<typeid(Value)>::const_reverse_iterator
|
||||
/// The type of a reference
|
||||
#define TYPEOF_REF(Value) TypeOf<typeid(Value)>::reference
|
||||
/// The type of a const reference
|
||||
#define TYPEOF_CREF(Value) TypeOf<typeid(Value)>::const_reference
|
||||
|
||||
/// Declare typeof magic for a specific type
|
||||
#define DECLARE_TYPEOF(T) \
|
||||
template<> struct TypeOf<typeid(T)> { \
|
||||
typedef T type; \
|
||||
typedef T::iterator iterator; \
|
||||
typedef T::const_iterator const_iterator; \
|
||||
typedef T::reverse_iterator reverse_iterator; \
|
||||
typedef T::const_reverse_iterator const_reverse_iterator; \
|
||||
typedef T::reference reference; \
|
||||
typedef T::const_reference const_reference; \
|
||||
}
|
||||
/// Declare typeof magic for a specific type that doesn't support reverse iterators
|
||||
#define DECLARE_TYPEOF_NO_REV(T) \
|
||||
template<> struct TypeOf<typeid(T)> { \
|
||||
typedef T type; \
|
||||
typedef T::iterator iterator; \
|
||||
typedef T::const_iterator const_iterator; \
|
||||
typedef T::reference reference; \
|
||||
typedef T::const_reference const_reference; \
|
||||
}
|
||||
/// Declare typeof magic for a specific type, using const iterators
|
||||
#define DECLARE_TYPEOF_CONST(T) \
|
||||
template<> struct TypeOf<typeid(T)> { \
|
||||
typedef T type; \
|
||||
typedef T::const_iterator iterator; \
|
||||
typedef T::const_iterator const_iterator; \
|
||||
typedef T::const_reverse_iterator reverse_iterator; \
|
||||
typedef T::const_reverse_iterator const_reverse_iterator; \
|
||||
typedef T::const_reference reference; \
|
||||
typedef T::const_reference const_reference; \
|
||||
}
|
||||
|
||||
/// Declare typeof magic for a specific std::vector type
|
||||
#define DECLARE_TYPEOF_COLLECTION(T) DECLARE_TYPEOF(vector< T >); \
|
||||
DECLARE_TYPEOF_CONST(set< T >)
|
||||
|
||||
#endif
|
||||
#define TYPEOF(Value) decltype(Value)
|
||||
#define TYPEOF_IT(Value) decltype((Value).begin())
|
||||
#define TYPEOF_CIT(Value) decltype((Value).begin())
|
||||
#define TYPEOF_RIT(Value) decltype((Value).rbegin())
|
||||
#define TYPEOF_CRIT(Value) decltype((Value).rbegin())
|
||||
#define TYPEOF_REF(Value) decltype(*(Value).begin())&
|
||||
#define TYPEOF_CREF(Value) decltype(*(Value).begin())&
|
||||
|
||||
/// Use for template classes
|
||||
/** i.e.
|
||||
@@ -151,15 +93,19 @@
|
||||
/// Iterate over a collection whos type must be declared with DECLARE_TYPEOF
|
||||
/** Usage: FOR_EACH(e,collect) { body-of-loop }
|
||||
*/
|
||||
#define FOR_EACH(Elem,Collection) \
|
||||
FOR_EACH_T(TYPEOF_IT(Collection), TYPEOF_REF(Collection), Elem, Collection, begin, end)
|
||||
//#define FOR_EACH(Elem,Collection) \
|
||||
// FOR_EACH_T(TYPEOF_IT(Collection), TYPEOF_REF(Collection), Elem, Collection, begin, end)
|
||||
#define FOR_EACH(Elem,Collection) \
|
||||
for (auto& Elem : Collection)
|
||||
|
||||
/// Iterate over a collection whos type must be declared with DECLARE_TYPEOF
|
||||
/** Uses a const iterator
|
||||
* Usage: FOR_EACH_CONST(e,collect) { body-of-loop }
|
||||
*/
|
||||
#define FOR_EACH_CONST(Elem,Collection) \
|
||||
FOR_EACH_T(TYPEOF_CIT(Collection), TYPEOF_CREF(Collection), Elem, Collection, begin, end)
|
||||
//#define FOR_EACH_CONST(Elem,Collection) \
|
||||
// FOR_EACH_T(TYPEOF_CIT(Collection), TYPEOF_CREF(Collection), Elem, Collection, begin, end)
|
||||
#define FOR_EACH_CONST(Elem,Collection) \
|
||||
for (auto const& Elem : Collection)
|
||||
|
||||
/// Iterate over a collection whos type must be declared with DECLARE_TYPEOF
|
||||
/** Iterates using a reverse_iterator
|
||||
|
||||
Reference in New Issue
Block a user