From 5956203258880a25d1705734e2bf57eb7a60a90c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 5 Jun 2021 11:09:13 +0100 Subject: Wrap DbValue in a class so we can add helpers to it --- lib/dbTypes.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'lib/dbTypes.h') diff --git a/lib/dbTypes.h b/lib/dbTypes.h index b35b036..068d642 100644 --- a/lib/dbTypes.h +++ b/lib/dbTypes.h @@ -33,8 +33,28 @@ namespace MyGrate { }; using Blob = std::span; - using DbValue = std::variant; + + class DbValue : public DbValueV { + public: + using DbValueV::DbValueV; + using DbValueV::operator=; + + template + inline auto + visit(V && v) const + { + return std::visit(std::forward(v), static_cast(*this)); + } + + template + inline const auto & + get() const + { + return std::get(static_cast(*this)); + } + }; } #endif -- cgit v1.2.3