different fix for MSVC compiler issues

This commit is contained in:
Vern Paxson 2023-04-18 17:12:52 -07:00
parent 1f61afa56b
commit 11dc4c8ce9
2 changed files with 6 additions and 8 deletions

View file

@ -28,11 +28,10 @@ struct NewRef
}; };
/** /**
* These have to be forward-declared and known here in order for us to be able * This has to be forward declared and known here in order for us to be able
* cast them in the `Unref` function. * cast this in the `Unref` function.
*/ */
class OpaqueVal; class OpaqueVal;
class TypeVal;
/** /**
* An intrusive, reference counting smart pointer implementation. Much like * An intrusive, reference counting smart pointer implementation. Much like
@ -121,10 +120,9 @@ public:
{ {
if ( ptr_ ) if ( ptr_ )
{ {
// For some `Val` subclasses the MSVC compiler does // Specializing `OpaqueVal` as MSVC compiler does not detect it
// not detect them as inheriting from `zeek::Obj`, // inheriting from `zeek::Obj` so we have to do that manually.
// so we have to do that manually. if constexpr ( std::is_same_v<T, OpaqueVal> )
if constexpr ( std::is_base_of_v<Obj, T> )
Unref(reinterpret_cast<zeek::Obj*>(ptr_)); Unref(reinterpret_cast<zeek::Obj*>(ptr_));
else else
Unref(ptr_); Unref(ptr_);

View file

@ -15,13 +15,13 @@
#include "zeek/IntrusivePtr.h" #include "zeek/IntrusivePtr.h"
#include "zeek/Obj.h" #include "zeek/Obj.h"
#include "zeek/Traverse.h" #include "zeek/Traverse.h"
#include "zeek/ZVal.h"
#include "zeek/ZeekList.h" #include "zeek/ZeekList.h"
namespace zeek namespace zeek
{ {
class Val; class Val;
union ZVal;
class EnumVal; class EnumVal;
class RecordVal; class RecordVal;
class TableVal; class TableVal;