#define MSP_CORE_META_H_
#include <cstddef>
+#include "attributes.h"
namespace Msp {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
template<typename T>
-struct RemoveConst
+struct DEPRECATED RemoveConst
{ typedef T Type; };
template<typename T>
-struct RemoveConst<const T>
+struct DEPRECATED RemoveConst<const T>
{ typedef T Type; };
template<typename T>
-struct RemoveReference
+struct DEPRECATED RemoveReference
{ typedef T Type; };
template<typename T>
-struct RemoveReference<T &>
+struct DEPRECATED RemoveReference<T &>
{ typedef T Type; };
template<typename T>
-struct RemoveConstReference
+struct DEPRECATED RemoveConstReference
{ typedef typename RemoveConst<typename RemoveReference<T>::Type>::Type Type; };
template<bool c, typename R>
-struct EnableIf;
+struct DEPRECATED EnableIf;
template<typename R>
-struct EnableIf<true, R>
+struct DEPRECATED EnableIf<true, R>
{ typedef R Yes; };
template<typename R>
-struct EnableIf<false, R>
+struct DEPRECATED EnableIf<false, R>
{ typedef R No; };
+#pragma GCC diagnostic pop
/**
#define MSP_CORE_VARIANT_H_
#include <stdexcept>
+#include <type_traits>
#include <typeinfo>
#include "meta.h"
virtual bool value_equals(const StoreBase &s) const { return value_equals_<T>(s); }
template<typename U>
- typename EnableIf<IsEqualityComparable<U>::value, bool>::Yes value_equals_(const StoreBase &s) const
+ typename std::enable_if<IsEqualityComparable<U>::value, bool>::type value_equals_(const StoreBase &s) const
{ const Store<T> *t = dynamic_cast<const Store<T> *>(&s); return (t && t->data==data); }
template<typename U>
- typename EnableIf<IsEqualityComparable<U>::value, bool>::No value_equals_(const StoreBase &) const
+ typename std::enable_if<!IsEqualityComparable<U>::value, bool>::type value_equals_(const StoreBase &) const
{ return false; }
};
public:
Variant(): store(0) { }
template<typename T>
- Variant(const T &v): store(new Store<typename RemoveConst<T>::Type>(v)) { }
+ Variant(const T &v): store(new Store<typename std::remove_cv<T>::type>(v)) { }
Variant(const Variant &v): store(v.store ? v.store->clone() : 0) { }
~Variant() { delete store; }
Variant &operator=(const T &v)
{
delete store;
- store = new Store<typename RemoveConst<T>::Type>(v);
+ store = new Store<typename std::remove_cv<T>::type>(v);
return *this;
}
private:
template<typename T>
- Store<typename RemoveConst<T>::Type> *get_typed_store() const
+ Store<typename std::remove_cv<T>::type> *get_typed_store() const
{
- typedef typename RemoveConst<T>::Type NCT;
+ typedef typename std::remove_cv<T>::type NCT;
Store<NCT> *s = dynamic_cast<Store<NCT> *>(store);
if(!s)
throw type_mismatch(typeid(T), (store ? store->type_id() : typeid(void)));
template<typename T>
bool check_type() const
{
- return dynamic_cast<Store<typename RemoveConst<T>::Type> *>(store)!=0;
+ return dynamic_cast<Store<typename std::remove_cv<T>::type> *>(store)!=0;
}
bool check_same_type(const Variant &v) const
using namespace Msp;
-template<typename T>
-struct IsSigned
-{ enum { result = !(static_cast<T>(-1)>0) }; };
-
/* Helper to avoid warnings about an unsigned type never being < 0 */
-template<typename T, bool f = IsSigned<T>::result>
+template<typename T, bool f = is_signed<T>::value>
struct IsNegative
{ static bool eval(T v) { return v<0; } };
/* Helper to avoid errors about ambiguous function calls since there are no
overloads of abs for unsigned types */
-template<typename T, bool f = IsSigned<T>::result>
+template<typename T, bool f = is_signed<T>::value>
struct Absolute
{ static T eval(T v) { return v<0 ? -v : v; } };
bool neg = false;
if(*i=='-')
{
- if(!IsSigned<T>::result)
+ if(is_unsigned<T>::value)
throw lexical_error(format("conversion of '%s' to unsigned integer", s));
neg = true;
++i;
template<typename T>
-typename EnableIf<HasFormattedOutput<T>::value, void>::Yes
+typename std::enable_if<HasFormattedOutput<T>::value>::type
operator<<(LexicalConverter &c, const T &v)
{
std::ostringstream ss;
}
template<typename T>
-typename EnableIf<HasFormattedInput<T>::value, void>::Yes
+typename std::enable_if<HasFormattedInput<T>::value>::type
operator>>(const LexicalConverter &c, T &v)
{
std::istringstream ss(c.get());