From d75fc3d5b663b1433f74e4261d2dc9fe06103f99 Mon Sep 17 00:00:00 2001 From: Patrick Urbanke Date: Mon, 6 Nov 2023 23:44:30 +0100 Subject: [PATCH] Added some standard methods to the validator --- include/rfl/Validator.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/rfl/Validator.hpp b/include/rfl/Validator.hpp index 1e02a9c6..e7813276 100644 --- a/include/rfl/Validator.hpp +++ b/include/rfl/Validator.hpp @@ -30,6 +30,10 @@ struct Validator { Validator() : value_(V::validate(T()).value()) {} + Validator(Validator&& _other) noexcept = default; + + Validator(const Validator& _other) = default; + Validator(const T& _value) : value_(V::validate(_value).value()) {} template , @@ -44,6 +48,18 @@ struct Validator { return *this; } + /// Assigns the underlying object. + auto& operator=(T&& _value) { + value_ = V::validate(_value).value(); + return *this; + } + + /// Assigns the underlying object. + Validator& operator=(const Validator& _other) = default; + + /// Assigns the underlying object. + Validator& operator=(Validator&& _other) = default; + /// Assigns the underlying object. template , bool>::type = true>