diff --git a/uppsrc/Core/Other.h b/uppsrc/Core/Other.h index 17c508133..7cda245f8 100644 --- a/uppsrc/Core/Other.h +++ b/uppsrc/Core/Other.h @@ -48,6 +48,9 @@ public: TT& Create() { TT *q = new TT; Attach(q); return *q; } T& Create() { T *q = new T; Attach(q); return *q; } + template + bool Is() const { return dynamic_cast(ptr); } + bool IsPicked() const { return ptr == (T*)1; } bool IsEmpty() const { Chk(); return !ptr; } diff --git a/uppsrc/Core/src.tpp/One$en-us.tpp b/uppsrc/Core/src.tpp/One$en-us.tpp index 6b567eec2..4857322a2 100644 --- a/uppsrc/Core/src.tpp/One$en-us.tpp +++ b/uppsrc/Core/src.tpp/One$en-us.tpp @@ -145,6 +145,12 @@ it.&] [s7;%% [*/ Return value]-|Reference to actual content (of type TT).&] [s3; &] [s4; &] +[s5;:One`:`:Is`(`)const: [@(0.0.255) template]_<[@(0.0.255) class]_[*@4 TT]>_[@(0.0.255) bool +]_[* Is]()_[@(0.0.255) const]&] +[s2;%% Returns true if One contains object of type [%-*@4 TT] or derived +from [%-*@4 TT]. [%-*@4 T] must be polymorphic.&] +[s3; &] +[s4; &] [s5;:One`:`:IsEmpty`(`)const: [@(0.0.255) bool]_[* IsEmpty]()_[@(0.0.255) const]&] [s2;%% Returns [* true] if there is no content.&] [s3; &] @@ -152,4 +158,4 @@ it.&] [s5;:One`:`:operator bool`(`)const: [* operator_bool]()_[@(0.0.255) const]&] [s2;%% Returns [* true] if there is content.&] [s3;%% &] -[s0; ] \ No newline at end of file +[s0; ]] \ No newline at end of file