forked from mirrors/gecko-dev
Bug 1881970 - Update function2 to 43fc0ca473ecb081918709bd7d524d84c2ff8dce r=nika
Differential Revision: https://phabricator.services.mozilla.com/D202673
This commit is contained in:
parent
21eca15ac3
commit
5454d094c7
3 changed files with 17 additions and 9 deletions
14
third_party/function2/Readme.md
vendored
14
third_party/function2/Readme.md
vendored
|
|
@ -63,7 +63,7 @@ Use `fu2::function` as a wrapper for copyable function wrappers and `fu2::unique
|
||||||
The standard implementation `std::function` and `fu2::function` are convertible to each other, see [the chapter convertibility of functions](#convertibility-of-functions) for details.
|
The standard implementation `std::function` and `fu2::function` are convertible to each other, see [the chapter convertibility of functions](#convertibility-of-functions) for details.
|
||||||
|
|
||||||
A function wrapper is declared as following:
|
A function wrapper is declared as following:
|
||||||
```cpp
|
```c++
|
||||||
fu2::function<void(int, float) const>
|
fu2::function<void(int, float) const>
|
||||||
// Return type ~^ ^ ^ ^
|
// Return type ~^ ^ ^ ^
|
||||||
// Parameters ~~~~~|~~~~~| ^
|
// Parameters ~~~~~|~~~~~| ^
|
||||||
|
|
@ -98,7 +98,7 @@ fu2::function<void(int, float) const>
|
||||||
|
|
||||||
`fu2::function` and `fu2::unique_function` (non copyable) are easy to use:
|
`fu2::function` and `fu2::unique_function` (non copyable) are easy to use:
|
||||||
|
|
||||||
```cpp
|
```c++
|
||||||
fu2::function<void() const> fun = [] {
|
fu2::function<void() const> fun = [] {
|
||||||
// ...
|
// ...
|
||||||
};
|
};
|
||||||
|
|
@ -111,7 +111,7 @@ fun();
|
||||||
|
|
||||||
`fu2::unique_function` also works with non copyable functors/ lambdas.
|
`fu2::unique_function` also works with non copyable functors/ lambdas.
|
||||||
|
|
||||||
```cpp
|
```c++
|
||||||
fu2::unique_function<bool() const> fun = [ptr = std::make_unique<bool>(true)] {
|
fu2::unique_function<bool() const> fun = [ptr = std::make_unique<bool>(true)] {
|
||||||
return *ptr;
|
return *ptr;
|
||||||
};
|
};
|
||||||
|
|
@ -127,7 +127,7 @@ otherfun();
|
||||||
|
|
||||||
A `fu2::function_view` can be used to create a non owning view on a persistent object. Note that the view is only valid as long as the object lives.
|
A `fu2::function_view` can be used to create a non owning view on a persistent object. Note that the view is only valid as long as the object lives.
|
||||||
|
|
||||||
```cpp
|
```c++
|
||||||
auto callable = [ptr = std::make_unique<bool>(true)] {
|
auto callable = [ptr = std::make_unique<bool>(true)] {
|
||||||
return *ptr;
|
return *ptr;
|
||||||
};
|
};
|
||||||
|
|
@ -164,7 +164,7 @@ fu2::function_view<bool() const> view(callable);
|
||||||
| fu2::unique_function | No | Yes | No |
|
| fu2::unique_function | No | Yes | No |
|
||||||
| std::function | Yes | Yes | Yes |
|
| std::function | Yes | Yes | Yes |
|
||||||
|
|
||||||
```cpp
|
```c++
|
||||||
fu2::function<void()> fun = []{};
|
fu2::function<void()> fun = []{};
|
||||||
// OK
|
// OK
|
||||||
std::function<void()> std_fun = fun;
|
std::function<void()> std_fun = fun;
|
||||||
|
|
@ -197,14 +197,14 @@ struct my_capacity {
|
||||||
|
|
||||||
The following code defines an owning function with a variadic signature which is copyable and sfo optimization is disabled:
|
The following code defines an owning function with a variadic signature which is copyable and sfo optimization is disabled:
|
||||||
|
|
||||||
```cpp
|
```c++
|
||||||
template<typename Signature>
|
template<typename Signature>
|
||||||
using my_function = fu2::function_base<true, true, fu2::capacity_none, true, false, Signature>;
|
using my_function = fu2::function_base<true, true, fu2::capacity_none, true, false, Signature>;
|
||||||
```
|
```
|
||||||
|
|
||||||
The following code defines a non copyable function which just takes 1 argument, and has a huge capacity for internal sfo optimization. Also it must be called as r-value.
|
The following code defines a non copyable function which just takes 1 argument, and has a huge capacity for internal sfo optimization. Also it must be called as r-value.
|
||||||
|
|
||||||
```cpp
|
```c++
|
||||||
template<typename Arg>
|
template<typename Arg>
|
||||||
using my_consumer = fu2::function_base<true, false, fu2::capacity_fixed<100U>,
|
using my_consumer = fu2::function_base<true, false, fu2::capacity_fixed<100U>,
|
||||||
true, false, void(Arg)&&>;
|
true, false, void(Arg)&&>;
|
||||||
|
|
|
||||||
|
|
@ -1828,6 +1828,14 @@ constexpr auto overload(T&&... callables) {
|
||||||
}
|
}
|
||||||
} // namespace fu2
|
} // namespace fu2
|
||||||
|
|
||||||
|
namespace std{
|
||||||
|
template <typename Config, typename Property, typename Alloc>
|
||||||
|
struct uses_allocator<
|
||||||
|
::fu2::detail::function<Config, Property>,
|
||||||
|
Alloc
|
||||||
|
> : std::true_type {};
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
#undef FU2_DETAIL_EXPAND_QUALIFIERS
|
#undef FU2_DETAIL_EXPAND_QUALIFIERS
|
||||||
#undef FU2_DETAIL_EXPAND_QUALIFIERS_NOEXCEPT
|
#undef FU2_DETAIL_EXPAND_QUALIFIERS_NOEXCEPT
|
||||||
#undef FU2_DETAIL_EXPAND_CV
|
#undef FU2_DETAIL_EXPAND_CV
|
||||||
|
|
|
||||||
4
third_party/function2/moz.yaml
vendored
4
third_party/function2/moz.yaml
vendored
|
|
@ -10,9 +10,9 @@ origin:
|
||||||
|
|
||||||
url: https://naios.github.io/function2/
|
url: https://naios.github.io/function2/
|
||||||
|
|
||||||
release: a354bd093d2b6e50c9325dbce84d20b4e77aabc6 (2023-11-04T12:44:54Z).
|
release: 43fc0ca473ecb081918709bd7d524d84c2ff8dce (2024-02-25T17:37:03Z).
|
||||||
|
|
||||||
revision: a354bd093d2b6e50c9325dbce84d20b4e77aabc6
|
revision: 43fc0ca473ecb081918709bd7d524d84c2ff8dce
|
||||||
|
|
||||||
license: BSL-1.0
|
license: BSL-1.0
|
||||||
license-file: LICENSE.txt
|
license-file: LICENSE.txt
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue