Skip to content

Cannot erase elements from toml::array because of compile errors #67

@std-any-emplace

Description

@std-any-emplace

This is from a unittest from a larger codebase:

TEST_CASE("toml.array", "does not compile")
{
	const auto data = R"(array=["v1", "v2", "v3"])"sv;

	auto table = toml::parse(data);
	auto arr = table["array"].as_array();

	REQUIRE(table["array"].as_array()->size() == 3);

	for (auto it = arr->cbegin(); it != arr->cend();)
		if (it->value_or(std::string{}) == "v2"s)
			it = arr->erase(it);
		else
			++it;

	REQUIRE(table["array"].as_array()->size() == 2);
}

This fails to compile with:

 /usr/include/toml++/toml_array.h:165:39: error: ?toml::v2::impl::array_iterator<IsConst>::array_iterator(toml::v2::impl::array_iterator<IsConst>::raw_mutable_iterator) [with bool IsConst = true; toml::v2::impl::array_iterator<IsConst>::raw_mutable_iterator = __gnu_cxx::__normal_iterator<std::unique_ptr<toml::v2::node>*, std::vector<std::unique_ptr<toml::v2::node> > >]? is private within this context
   165 |     return array_iterator<true>{ raw_ };
       |                                       ^
 /usr/include/toml++/toml_array.h:23:4: note: declared private here
    23 |    array_iterator(raw_mutable_iterator raw) noexcept
       |    ^~~~~~~~~~~~~~

Using GCC 9.3.0 and tomlplusplus-2.2.0.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions