mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 11:36:10 +00:00
AK: Fix the JsonArray constructor for accepting an iterable type
There were a couple of issues here. First, the IterableContainerOf concept was testing if dereferencing an iterator of ContainerType<T> returns a value of type T. However, it should return a T&. Second, the constructor was trying to move values out of a constant reference to the container. We now accept both lvalue and rvalue containers.
This commit is contained in:
parent
38197916c3
commit
1adcaf7181
Notes:
github-actions[bot]
2025-03-04 20:35:11 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/1adcaf71815 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3801 Reviewed-by: https://github.com/AtkinsSJ
2 changed files with 9 additions and 2 deletions
|
@ -126,7 +126,7 @@ template<typename T, typename ValueT>
|
|||
concept IterableContainerOf = IterableContainer<T> && requires {
|
||||
{
|
||||
*declval<T>().begin()
|
||||
} -> SameAs<ValueT>;
|
||||
} -> SameAs<ValueT&>;
|
||||
};
|
||||
|
||||
template<typename Func, typename... Args>
|
||||
|
|
|
@ -38,12 +38,19 @@ public:
|
|||
}
|
||||
|
||||
template<IterableContainerOf<JsonValue> ContainerT>
|
||||
JsonArray(ContainerT const& source)
|
||||
JsonArray(ContainerT&& source)
|
||||
{
|
||||
for (auto& value : source)
|
||||
m_values.append(move(value));
|
||||
}
|
||||
|
||||
template<IterableContainerOf<JsonValue> ContainerT>
|
||||
JsonArray(ContainerT const& source)
|
||||
{
|
||||
for (auto const& value : source)
|
||||
m_values.append(value);
|
||||
}
|
||||
|
||||
JsonArray& operator=(JsonArray const& other)
|
||||
{
|
||||
if (this != &other)
|
||||
|
|
Loading…
Add table
Reference in a new issue