Skip to content

Commit

Permalink
Added static_asserts to make sure that only tables can be used as roo…
Browse files Browse the repository at this point in the history
…t elements
  • Loading branch information
liuzicheng1987 committed Mar 29, 2024
1 parent fd5c463 commit 661c2d2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions include/rfl/toml/Writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,23 @@ class Writer {

~Writer() = default;

OutputArrayType array_as_root(const size_t _size) const noexcept {
value_as_root(_size);
template <class T>
OutputArrayType array_as_root(const T _size) const noexcept {
static_assert(rfl::always_false_v<T>,
"TOML only allows tables as the root element.");
return OutputArrayType{nullptr};
}

OutputObjectType object_as_root(const size_t _size) const noexcept {
return OutputObjectType{root_};
}

OutputVarType null_as_root() const noexcept { return value_as_root(0); }
OutputVarType null_as_root() const noexcept { return OutputVarType{}; }

template <class T>
OutputVarType value_as_root(const T& _var) const noexcept {
// TODO
// static_assert(rfl::always_false_v<T>,
// "TOML only allows tables as its root.");
static_assert(rfl::always_false_v<T>,
"TOML only allows tables as the root element.");
return OutputVarType{};
}

Expand Down

0 comments on commit 661c2d2

Please sign in to comment.