added index attribute to field class

This commit is contained in:
2024-03-10 17:22:38 +01:00
parent 6bbc870362
commit 9a02abacea
3 changed files with 22 additions and 4 deletions
+4 -1
View File
@@ -64,8 +64,9 @@ class field
public:
explicit field(std::string name);
template<typename Type>
field(std::string name, Type value)
field(std::string name, Type value, int index = -1)
: name_(std::move(name))
, index_(index)
, value_(value)
, type_(field_traits<Type>::type()) {}
field(const field &x) = default;
@@ -81,6 +82,7 @@ public:
}
[[nodiscard]] const std::string& name() const;
[[nodiscard]] int index() const;
template<class Type>
std::optional<Type> as() const
@@ -103,6 +105,7 @@ public:
private:
std::string name_;
int index_{-1};
any_type value_;
field_type type_;
};