mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-20 20:23:03 +02:00
Fix SonarCloud issues
Replace the use of "::value" with "std::is_abstract_v" and similar issues
This commit is contained in:
parent
00058ea609
commit
ea48257100
@ -194,7 +194,7 @@ public:
|
||||
template<typename Container>
|
||||
int3 findClosestTile (Container & container, int3 dest)
|
||||
{
|
||||
static_assert(std::is_same<typename Container::value_type, int3>::value,
|
||||
static_assert(std::is_same_v<typename Container::value_type, int3>,
|
||||
"findClosestTile requires <int3> container.");
|
||||
|
||||
int3 result(-1, -1, -1);
|
||||
|
@ -96,7 +96,7 @@ class DLL_LINKAGE BinaryDeserializer : public CLoaderBase
|
||||
{
|
||||
static T *invoke(IGameCallback *cb)
|
||||
{
|
||||
static_assert(!std::is_abstract<T>::value, "Cannot call new upon abstract classes!");
|
||||
static_assert(!std::is_abstract_v<T>, "Cannot call new upon abstract classes!");
|
||||
return new T(cb);
|
||||
}
|
||||
};
|
||||
@ -171,21 +171,21 @@ public:
|
||||
return * this;
|
||||
}
|
||||
|
||||
template < class T, typename std::enable_if < std::is_fundamental<T>::value && !std::is_same<T, bool>::value, int >::type = 0 >
|
||||
template < class T, typename std::enable_if_t < std::is_fundamental_v<T> && !std::is_same_v<T, bool>, int > = 0 >
|
||||
void load(T &data)
|
||||
{
|
||||
this->read(static_cast<void *>(&data), sizeof(data), reverseEndianess);
|
||||
}
|
||||
|
||||
template < typename T, typename std::enable_if < is_serializeable<BinaryDeserializer, T>::value, int >::type = 0 >
|
||||
template < typename T, typename std::enable_if_t < is_serializeable<BinaryDeserializer, T>::value, int > = 0 >
|
||||
void load(T &data)
|
||||
{
|
||||
////that const cast is evil because it allows to implicitly overwrite const objects when deserializing
|
||||
typedef typename std::remove_const<T>::type nonConstT;
|
||||
typedef typename std::remove_const_t<T> nonConstT;
|
||||
auto & hlp = const_cast<nonConstT &>(data);
|
||||
hlp.serialize(*this);
|
||||
}
|
||||
template < typename T, typename std::enable_if < std::is_array<T>::value, int >::type = 0 >
|
||||
template < typename T, typename std::enable_if_t < std::is_array_v<T>, int > = 0 >
|
||||
void load(T &data)
|
||||
{
|
||||
ui32 size = std::size(data);
|
||||
@ -193,7 +193,7 @@ public:
|
||||
load(data[i]);
|
||||
}
|
||||
|
||||
template < typename T, typename std::enable_if < std::is_enum<T>::value, int >::type = 0 >
|
||||
template < typename T, typename std::enable_if_t < std::is_enum_v<T>, int > = 0 >
|
||||
void load(T &data)
|
||||
{
|
||||
si32 read;
|
||||
@ -201,7 +201,7 @@ public:
|
||||
data = static_cast<T>(read);
|
||||
}
|
||||
|
||||
template < typename T, typename std::enable_if < std::is_same<T, bool>::value, int >::type = 0 >
|
||||
template < typename T, typename std::enable_if_t < std::is_same_v<T, bool>, int > = 0 >
|
||||
void load(T &data)
|
||||
{
|
||||
ui8 read;
|
||||
@ -209,7 +209,7 @@ public:
|
||||
data = static_cast<bool>(read);
|
||||
}
|
||||
|
||||
template <typename T, typename std::enable_if < !std::is_same<T, bool >::value, int >::type = 0>
|
||||
template <typename T, typename std::enable_if_t < !std::is_same_v<T, bool >, int > = 0>
|
||||
void load(std::vector<T> &data)
|
||||
{
|
||||
ui32 length = readAndCheckLength();
|
||||
@ -218,7 +218,7 @@ public:
|
||||
load( data[i]);
|
||||
}
|
||||
|
||||
template < typename T, typename std::enable_if < std::is_pointer<T>::value, int >::type = 0 >
|
||||
template < typename T, typename std::enable_if_t < std::is_pointer_v<T>, int > = 0 >
|
||||
void load(T &data)
|
||||
{
|
||||
bool isNull;
|
||||
@ -232,7 +232,7 @@ public:
|
||||
loadPointerImpl(data);
|
||||
}
|
||||
|
||||
template < typename T, typename std::enable_if < std::is_base_of_v<Entity, std::remove_pointer_t<T>>, int >::type = 0 >
|
||||
template < typename T, typename std::enable_if_t < std::is_base_of_v<Entity, std::remove_pointer_t<T>>, int > = 0 >
|
||||
void loadPointerImpl(T &data)
|
||||
{
|
||||
using DataType = std::remove_pointer_t<T>;
|
||||
@ -245,12 +245,12 @@ public:
|
||||
data = const_cast<DataType *>(constData);
|
||||
}
|
||||
|
||||
template < typename T, typename std::enable_if < !std::is_base_of_v<Entity, std::remove_pointer_t<T>>, int >::type = 0 >
|
||||
template < typename T, typename std::enable_if_t < !std::is_base_of_v<Entity, std::remove_pointer_t<T>>, int > = 0 >
|
||||
void loadPointerImpl(T &data)
|
||||
{
|
||||
if(reader->smartVectorMembersSerialization)
|
||||
{
|
||||
typedef typename std::remove_const<typename std::remove_pointer<T>::type>::type TObjectType; //eg: const CGHeroInstance * => CGHeroInstance
|
||||
typedef typename std::remove_const_t<typename std::remove_pointer_t<T>> TObjectType; //eg: const CGHeroInstance * => CGHeroInstance
|
||||
typedef typename VectorizedTypeFor<TObjectType>::type VType; //eg: CGHeroInstance -> CGobjectInstance
|
||||
typedef typename VectorizedIDType<TObjectType>::type IDType;
|
||||
if(const auto *info = reader->getVectorizedTypeInfo<VType, IDType>())
|
||||
@ -292,8 +292,8 @@ public:
|
||||
|
||||
if(!tid)
|
||||
{
|
||||
typedef typename std::remove_pointer<T>::type npT;
|
||||
typedef typename std::remove_const<npT>::type ncpT;
|
||||
typedef typename std::remove_pointer_t<T> npT;
|
||||
typedef typename std::remove_const_t<npT> ncpT;
|
||||
data = ClassObjectCreator<ncpT>::invoke(cb);
|
||||
ptrAllocated(data, pid);
|
||||
load(*data);
|
||||
@ -326,7 +326,7 @@ public:
|
||||
template <typename T>
|
||||
void load(std::shared_ptr<T> &data)
|
||||
{
|
||||
typedef typename std::remove_const<T>::type NonConstT;
|
||||
typedef typename std::remove_const_t<T> NonConstT;
|
||||
NonConstT *internalPtr;
|
||||
load(internalPtr);
|
||||
|
||||
|
@ -134,28 +134,28 @@ public:
|
||||
return * this;
|
||||
}
|
||||
|
||||
template < typename T, typename std::enable_if < std::is_same<T, bool>::value, int >::type = 0 >
|
||||
template < typename T, typename std::enable_if_t < std::is_same_v<T, bool>, int > = 0 >
|
||||
void save(const T &data)
|
||||
{
|
||||
ui8 writ = static_cast<ui8>(data);
|
||||
save(writ);
|
||||
}
|
||||
|
||||
template < class T, typename std::enable_if < std::is_fundamental<T>::value && !std::is_same<T, bool>::value, int >::type = 0 >
|
||||
template < class T, typename std::enable_if_t < std::is_fundamental_v<T> && !std::is_same_v<T, bool>, int > = 0 >
|
||||
void save(const T &data)
|
||||
{
|
||||
// save primitive - simply dump binary data to output
|
||||
this->write(static_cast<const void *>(&data), sizeof(data));
|
||||
}
|
||||
|
||||
template < typename T, typename std::enable_if < std::is_enum<T>::value, int >::type = 0 >
|
||||
template < typename T, typename std::enable_if_t < std::is_enum_v<T>, int > = 0 >
|
||||
void save(const T &data)
|
||||
{
|
||||
si32 writ = static_cast<si32>(data);
|
||||
*this & writ;
|
||||
}
|
||||
|
||||
template < typename T, typename std::enable_if < std::is_array<T>::value, int >::type = 0 >
|
||||
template < typename T, typename std::enable_if_t < std::is_array_v<T>, int > = 0 >
|
||||
void save(const T &data)
|
||||
{
|
||||
ui32 size = std::size(data);
|
||||
@ -163,7 +163,7 @@ public:
|
||||
*this & data[i];
|
||||
}
|
||||
|
||||
template < typename T, typename std::enable_if < std::is_pointer<T>::value, int >::type = 0 >
|
||||
template < typename T, typename std::enable_if_t < std::is_pointer_v<T>, int > = 0 >
|
||||
void save(const T &data)
|
||||
{
|
||||
//write if pointer is not nullptr
|
||||
@ -177,17 +177,17 @@ public:
|
||||
savePointerImpl(data);
|
||||
}
|
||||
|
||||
template < typename T, typename std::enable_if < std::is_base_of_v<Entity, std::remove_pointer_t<T>>, int >::type = 0 >
|
||||
template < typename T, typename std::enable_if_t < std::is_base_of_v<Entity, std::remove_pointer_t<T>>, int > = 0 >
|
||||
void savePointerImpl(const T &data)
|
||||
{
|
||||
auto index = data->getId();
|
||||
save(index);
|
||||
}
|
||||
|
||||
template < typename T, typename std::enable_if < !std::is_base_of_v<Entity, std::remove_pointer_t<T>>, int >::type = 0 >
|
||||
template < typename T, typename std::enable_if_t < !std::is_base_of_v<Entity, std::remove_pointer_t<T>>, int > = 0 >
|
||||
void savePointerImpl(const T &data)
|
||||
{
|
||||
typedef typename std::remove_const<typename std::remove_pointer<T>::type>::type TObjectType;
|
||||
typedef typename std::remove_const_t<typename std::remove_pointer_t<T>> TObjectType;
|
||||
|
||||
if(writer->smartVectorMembersSerialization)
|
||||
{
|
||||
@ -239,7 +239,7 @@ public:
|
||||
applier.getApplier(tid)->savePtr(*this, static_cast<const void*>(data)); //call serializer specific for our real type
|
||||
}
|
||||
|
||||
template < typename T, typename std::enable_if < is_serializeable<BinarySerializer, T>::value, int >::type = 0 >
|
||||
template < typename T, typename std::enable_if_t < is_serializeable<BinarySerializer, T>::value, int > = 0 >
|
||||
void save(const T &data)
|
||||
{
|
||||
const_cast<T&>(data).serialize(*this);
|
||||
@ -268,7 +268,7 @@ public:
|
||||
T *internalPtr = data.get();
|
||||
save(internalPtr);
|
||||
}
|
||||
template <typename T, typename std::enable_if < !std::is_same<T, bool >::value, int >::type = 0>
|
||||
template <typename T, typename std::enable_if_t < !std::is_same_v<T, bool >, int > = 0>
|
||||
void save(const std::vector<T> &data)
|
||||
{
|
||||
ui32 length = (ui32)data.size();
|
||||
|
@ -138,7 +138,7 @@ struct is_serializeable
|
||||
template<class U>
|
||||
static Yes test(U * data, S* arg1 = nullptr, typename std::enable_if_t<std::is_void_v<decltype(data->serialize(*arg1))>> * = nullptr);
|
||||
static No test(...);
|
||||
static const bool value = sizeof(Yes) == sizeof(is_serializeable::test((typename std::remove_reference<typename std::remove_cv<T>::type>::type*)nullptr));
|
||||
static const bool value = sizeof(Yes) == sizeof(is_serializeable::test((typename std::remove_reference_t<typename std::remove_cv_t<T>>*)nullptr));
|
||||
};
|
||||
|
||||
template <typename T> //metafunction returning CGObjectInstance if T is its derivate or T elsewise
|
||||
|
@ -15,8 +15,8 @@
|
||||
|
||||
VCMI_LIB_USING_NAMESPACE
|
||||
|
||||
using NumericPointer = typename std::conditional<sizeof(void *) == sizeof(unsigned long long),
|
||||
unsigned long long, unsigned int>::type;
|
||||
using NumericPointer = typename std::conditional_t<sizeof(void *) == sizeof(unsigned long long),
|
||||
unsigned long long, unsigned int>;
|
||||
|
||||
template<class Type>
|
||||
NumericPointer data_cast(Type * _pointer)
|
||||
|
@ -26,13 +26,13 @@ namespace detail
|
||||
template<typename T>
|
||||
struct IsRegularClass
|
||||
{
|
||||
static constexpr auto value = std::is_class<T>::value && !std::is_base_of<IdentifierBase, T>::value;
|
||||
static constexpr auto value = std::is_class_v<T> && !std::is_base_of_v<IdentifierBase, T>;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct IsIdClass
|
||||
{
|
||||
static constexpr auto value = std::is_class<T>::value && std::is_base_of<IdentifierBase, T>::value;
|
||||
static constexpr auto value = std::is_class_v<T> && std::is_base_of_v<IdentifierBase, T>;
|
||||
};
|
||||
}
|
||||
|
||||
@ -61,13 +61,13 @@ public:
|
||||
pushNil();
|
||||
}
|
||||
|
||||
template<typename T, typename std::enable_if< std::is_integral<T>::value && !std::is_same<T, bool>::value, int>::type = 0>
|
||||
template<typename T, typename std::enable_if_t< std::is_integral_v<T> && !std::is_same_v<T, bool>, int> = 0>
|
||||
void push(const T value)
|
||||
{
|
||||
pushInteger(static_cast<lua_Integer>(value));
|
||||
}
|
||||
|
||||
template<typename T, typename std::enable_if< std::is_enum<T>::value, int>::type = 0>
|
||||
template<typename T, typename std::enable_if_t< std::is_enum_v<T>, int> = 0>
|
||||
void push(const T value)
|
||||
{
|
||||
pushInteger(static_cast<lua_Integer>(value));
|
||||
@ -75,13 +75,13 @@ public:
|
||||
|
||||
void push(const int3 & value);
|
||||
|
||||
template<typename T, typename std::enable_if< detail::IsIdClass<T>::value, int>::type = 0>
|
||||
template<typename T, typename std::enable_if_t< detail::IsIdClass<T>::value, int> = 0>
|
||||
void push(const T & value)
|
||||
{
|
||||
pushInteger(static_cast<lua_Integer>(value.getNum()));
|
||||
}
|
||||
|
||||
template<typename T, typename std::enable_if<detail::IsRegularClass<T>::value, int>::type = 0>
|
||||
template<typename T, typename std::enable_if_t<detail::IsRegularClass<T>::value, int> = 0>
|
||||
void push(T * value)
|
||||
{
|
||||
using UData = T *;
|
||||
@ -107,7 +107,7 @@ public:
|
||||
lua_setmetatable(L, -2);
|
||||
}
|
||||
|
||||
template<typename T, typename std::enable_if<detail::IsRegularClass<T>::value, int>::type = 0>
|
||||
template<typename T, typename std::enable_if_t<detail::IsRegularClass<T>::value, int> = 0>
|
||||
void push(std::shared_ptr<T> value)
|
||||
{
|
||||
using UData = std::shared_ptr<T>;
|
||||
@ -133,7 +133,7 @@ public:
|
||||
lua_setmetatable(L, -2);
|
||||
}
|
||||
|
||||
template<typename T, typename std::enable_if<detail::IsRegularClass<T>::value, int>::type = 0>
|
||||
template<typename T, typename std::enable_if_t<detail::IsRegularClass<T>::value, int> = 0>
|
||||
void push(std::unique_ptr<T> && value)
|
||||
{
|
||||
using UData = std::unique_ptr<T>;
|
||||
@ -163,7 +163,7 @@ public:
|
||||
|
||||
bool tryGet(int position, bool & value);
|
||||
|
||||
template<typename T, typename std::enable_if< std::is_integral<T>::value && !std::is_same<T, bool>::value, int>::type = 0>
|
||||
template<typename T, typename std::enable_if_t< std::is_integral_v<T> && !std::is_same_v<T, bool>, int> = 0>
|
||||
bool tryGet(int position, T & value)
|
||||
{
|
||||
lua_Integer temp;
|
||||
@ -178,7 +178,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename std::enable_if<detail::IsIdClass<T>::value, int>::type = 0>
|
||||
template<typename T, typename std::enable_if_t<detail::IsIdClass<T>::value, int> = 0>
|
||||
bool tryGet(int position, T & value)
|
||||
{
|
||||
lua_Integer temp;
|
||||
@ -193,7 +193,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename std::enable_if< std::is_enum<T>::value, int>::type = 0>
|
||||
template<typename T, typename std::enable_if_t< std::is_enum_v<T>, int> = 0>
|
||||
bool tryGet(int position, T & value)
|
||||
{
|
||||
lua_Integer temp;
|
||||
@ -213,10 +213,10 @@ public:
|
||||
bool tryGet(int position, double & value);
|
||||
bool tryGet(int position, std::string & value);
|
||||
|
||||
template<typename T, typename std::enable_if<detail::IsRegularClass<T>::value && std::is_const<T>::value, int>::type = 0>
|
||||
template<typename T, typename std::enable_if_t<detail::IsRegularClass<T>::value && std::is_const_v<T>, int> = 0>
|
||||
STRONG_INLINE bool tryGet(int position, T * & value)
|
||||
{
|
||||
using NCValue = typename std::remove_const<T>::type;
|
||||
using NCValue = typename std::remove_const_t<T>;
|
||||
|
||||
using UData = NCValue *;
|
||||
using CUData = T *;
|
||||
@ -224,16 +224,16 @@ public:
|
||||
return tryGetCUData<T *, UData, CUData>(position, value);
|
||||
}
|
||||
|
||||
template<typename T, typename std::enable_if<detail::IsRegularClass<T>::value && !std::is_const<T>::value, int>::type = 0>
|
||||
template<typename T, typename std::enable_if_t<detail::IsRegularClass<T>::value && !std::is_const_v<T>, int> = 0>
|
||||
STRONG_INLINE bool tryGet(int position, T * & value)
|
||||
{
|
||||
return tryGetUData<T *>(position, value);
|
||||
}
|
||||
|
||||
template<typename T, typename std::enable_if<detail::IsRegularClass<T>::value && std::is_const<T>::value, int>::type = 0>
|
||||
template<typename T, typename std::enable_if_t<detail::IsRegularClass<T>::value && std::is_const_v<T>, int> = 0>
|
||||
STRONG_INLINE bool tryGet(int position, std::shared_ptr<T> & value)
|
||||
{
|
||||
using NCValue = typename std::remove_const<T>::type;
|
||||
using NCValue = typename std::remove_const_t<T>;
|
||||
|
||||
using UData = std::shared_ptr<NCValue>;
|
||||
using CUData = std::shared_ptr<T>;
|
||||
@ -241,7 +241,7 @@ public:
|
||||
return tryGetCUData<std::shared_ptr<T>, UData, CUData>(position, value);
|
||||
}
|
||||
|
||||
template<typename T, typename std::enable_if<detail::IsRegularClass<T>::value && !std::is_const<T>::value, int>::type = 0>
|
||||
template<typename T, typename std::enable_if_t<detail::IsRegularClass<T>::value && !std::is_const_v<T>, int> = 0>
|
||||
STRONG_INLINE bool tryGet(int position, std::shared_ptr<T> & value)
|
||||
{
|
||||
return tryGetUData<std::shared_ptr<T>>(position, value);
|
||||
|
@ -124,7 +124,7 @@ template<class T, class Proxy = T>
|
||||
class OpaqueWrapper : public RegistarBase
|
||||
{
|
||||
public:
|
||||
using ObjectType = typename std::remove_cv<T>::type;
|
||||
using ObjectType = typename std::remove_cv_t<T>;
|
||||
using UDataType = ObjectType *;
|
||||
using CUDataType = const ObjectType *;
|
||||
|
||||
@ -163,7 +163,7 @@ template<class T, class Proxy = T>
|
||||
class SharedWrapper : public RegistarBase
|
||||
{
|
||||
public:
|
||||
using ObjectType = typename std::remove_cv<T>::type;
|
||||
using ObjectType = typename std::remove_cv_t<T>;
|
||||
using UDataType = std::shared_ptr<T>;
|
||||
using CustomRegType = detail::CustomRegType;
|
||||
|
||||
@ -208,7 +208,7 @@ template<class T, class Proxy = T>
|
||||
class UniqueOpaqueWrapper : public api::Registar
|
||||
{
|
||||
public:
|
||||
using ObjectType = typename std::remove_cv<T>::type;
|
||||
using ObjectType = typename std::remove_cv_t<T>;
|
||||
using UDataType = std::unique_ptr<T>;
|
||||
using CustomRegType = detail::CustomRegType;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
using EventType = typename EventProxy::ObjectType;
|
||||
using RegistryType = ::events::SubscriptionRegistry<EventType>;
|
||||
|
||||
static_assert(std::is_base_of<::events::Event, EventType>::value, "Invalid template parameter");
|
||||
static_assert(std::is_base_of_v<::events::Event, EventType>, "Invalid template parameter");
|
||||
|
||||
static int subscribeBefore(lua_State * L)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user