diff --git a/src/lib/variant.hpp b/src/lib/variant.hpp index 5884134fd..d675e233f 100644 --- a/src/lib/variant.hpp +++ b/src/lib/variant.hpp @@ -224,8 +224,9 @@ namespace lib { virtual ~Buffer() {} ///< this is an ABC with VTable - virtual void dispatch (Visitor&) =0; - virtual operator string() const =0; + virtual void dispatch (Visitor&) =0; + virtual bool dispatch (Predicate&) const =0; + virtual operator string() const =0; }; @@ -317,6 +318,15 @@ namespace lib { typeDispatcher.handle (this->access()); } + bool + dispatch (Predicate& visitor) const + { + using Dispatcher = VFunc::template ValueAcceptInterface; + + Dispatcher& typeDispatcher = visitor; + return typeDispatcher.handle (this->access()); + } + /** diagnostic helper */ operator string() const; }; @@ -452,6 +462,12 @@ namespace lib { { buffer().dispatch (visitor); } + + bool + accept (Predicate& visitor) const + { + return buffer().dispatch (visitor); + } };