mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-20 04:26:03 +08:00
Correct is_pod_v usage
This commit is contained in:
@ -17,6 +17,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "tier0/dbg.h"
|
#include "tier0/dbg.h"
|
||||||
|
#include "utlcommon.h"
|
||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
#include "mathlib/vector4d.h"
|
#include "mathlib/vector4d.h"
|
||||||
@ -27,7 +28,6 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
@ -742,7 +742,7 @@ struct CVarTypeTraits
|
|||||||
{
|
{
|
||||||
m_TypeName = name;
|
m_TypeName = name;
|
||||||
m_ByteSize = sizeof( T );
|
m_ByteSize = sizeof( T );
|
||||||
m_IsPrimitive = std::is_pod_v<T>;
|
m_IsPrimitive = CTypePOD<T>;
|
||||||
|
|
||||||
Construct = &CvarTypeTrait_ConstructFn<T>;
|
Construct = &CvarTypeTrait_ConstructFn<T>;
|
||||||
Copy = &CvarTypeTrait_CopyFn<T>;
|
Copy = &CvarTypeTrait_CopyFn<T>;
|
||||||
@ -1085,7 +1085,7 @@ public:
|
|||||||
// (which will happen in callbacks), so the solution is to do a static_cast to
|
// (which will happen in callbacks), so the solution is to do a static_cast to
|
||||||
// CConVarRef<T> yourself on the cvar you receive in a callback and call .Set() on it
|
// CConVarRef<T> yourself on the cvar you receive in a callback and call .Set() on it
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void SetAs( T value, CSplitScreenSlot slot = -1 );
|
void SetAs( const T &value, CSplitScreenSlot slot = -1 );
|
||||||
|
|
||||||
// Attempts to set value as a bool, does type conversion if possible,
|
// Attempts to set value as a bool, does type conversion if possible,
|
||||||
// if no such action is available for CvarType/bool combo, no action would be done
|
// if no such action is available for CvarType/bool combo, no action would be done
|
||||||
@ -1135,7 +1135,7 @@ protected:
|
|||||||
T ConvertFromPrimitiveTo( CSplitScreenSlot slot ) const;
|
T ConvertFromPrimitiveTo( CSplitScreenSlot slot ) const;
|
||||||
// Does type conversion from type T to CvarType, only valid for primitive types
|
// Does type conversion from type T to CvarType, only valid for primitive types
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void ConvertToPrimitiveFrom( CSplitScreenSlot slot, T value ) const;
|
void ConvertToPrimitiveFrom( CSplitScreenSlot slot, const T &value ) const;
|
||||||
|
|
||||||
// Initialises this cvar, if ref is invalid, ConVarData would be initialised to invalid convar data of a set type
|
// Initialises this cvar, if ref is invalid, ConVarData would be initialised to invalid convar data of a set type
|
||||||
void Init( ConVarRef ref, EConVarType type = EConVarType_Invalid );
|
void Init( ConVarRef ref, EConVarType type = EConVarType_Invalid );
|
||||||
@ -1298,7 +1298,7 @@ inline CUtlString ConVarRefAbstract::GetString( CSplitScreenSlot slot ) const
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
inline T ConVarRefAbstract::ConvertFromPrimitiveTo( CSplitScreenSlot slot ) const
|
inline T ConVarRefAbstract::ConvertFromPrimitiveTo( CSplitScreenSlot slot ) const
|
||||||
{
|
{
|
||||||
if constexpr(std::is_pod_v<T>)
|
if constexpr(CTypePOD<T>)
|
||||||
{
|
{
|
||||||
CVValue_t *value = m_ConVarData->ValueOrDefault( slot );
|
CVValue_t *value = m_ConVarData->ValueOrDefault( slot );
|
||||||
|
|
||||||
@ -1337,7 +1337,7 @@ inline void CConVarRef<T>::Set( const T &value, CSplitScreenSlot slot )
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline void ConVarRefAbstract::SetAs( T value, CSplitScreenSlot slot )
|
inline void ConVarRefAbstract::SetAs( const T &value, CSplitScreenSlot slot )
|
||||||
{
|
{
|
||||||
if(GetType() == TranslateConVarType<T>())
|
if(GetType() == TranslateConVarType<T>())
|
||||||
{
|
{
|
||||||
@ -1357,15 +1357,15 @@ inline void ConVarRefAbstract::SetAs( T value, CSplitScreenSlot slot )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> inline void ConVarRefAbstract::SetAs( CUtlString value, CSplitScreenSlot slot )
|
template<> inline void ConVarRefAbstract::SetAs( const CUtlString &value, CSplitScreenSlot slot )
|
||||||
{
|
{
|
||||||
SetString( value, slot );
|
SetString( value, slot );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline void ConVarRefAbstract::ConvertToPrimitiveFrom( CSplitScreenSlot slot, T value ) const
|
inline void ConVarRefAbstract::ConvertToPrimitiveFrom( CSplitScreenSlot slot, const T &value ) const
|
||||||
{
|
{
|
||||||
if constexpr(std::is_pod_v<T>)
|
if constexpr(CTypePOD<T>)
|
||||||
{
|
{
|
||||||
switch(GetType())
|
switch(GetType())
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "utlstring.h"
|
#include "utlstring.h"
|
||||||
|
#include "type_traits"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Henry Goffin (henryg) was here. Questions? Bugs? Go slap him around a bit.
|
// Henry Goffin (henryg) was here. Questions? Bugs? Go slap him around a bit.
|
||||||
@ -47,6 +48,9 @@ struct CTypeEquals<A, B, true, false> : CTypeEquals< const volatile A, const vol
|
|||||||
template <typename A, typename B>
|
template <typename A, typename B>
|
||||||
struct CTypeEquals<A, B, false, true> : CTypeEquals< A&, B& > {};
|
struct CTypeEquals<A, B, false, true> : CTypeEquals< A&, B& > {};
|
||||||
|
|
||||||
|
template <typename A>
|
||||||
|
constexpr bool CTypePOD = std::is_standard_layout_v<A> && std::is_trivial_v<A>;
|
||||||
|
|
||||||
// CUtlKeyValuePair is intended for use with key-lookup containers.
|
// CUtlKeyValuePair is intended for use with key-lookup containers.
|
||||||
// Because it is specialized for "empty_t" values, one container can
|
// Because it is specialized for "empty_t" values, one container can
|
||||||
// function as either a set of keys OR a key-value dictionary while
|
// function as either a set of keys OR a key-value dictionary while
|
||||||
|
Reference in New Issue
Block a user