-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
344 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Class `explicit_conversion_dispatch` | ||
|
||
```cpp | ||
class explicit_conversion_dispatch; | ||
|
||
using conversion_dispatch = explicit_conversion_dispatch; | ||
``` | ||
|
||
Class `explicit_conversion_dispatch` models a [dispatch](ProDispatch.md) type for explicit type conversion expressions. It meets the [*ProAccessible* requirements](ProAccessible.md) of applicable types. `conversion_dispatch` is an alias of `explicit_conversion_dispatch`. | ||
|
||
## Member Functions | ||
|
||
| Name | Description | | ||
| ------------------------------------------------------------ | --------------------------------------------------- | | ||
| (constructor) [nothrow] | constructs an `explicit_conversion_dispatch` object | | ||
| [`operator()`](explicit_conversion_dispatch/operator_call.md) | invokes the dispatch | | ||
|
||
## Member Types | ||
|
||
| Name | Description | | ||
| ------------------------------------------------------ | --------------------------------- | | ||
| [`accessor`](explicit_conversion_dispatch/accessor.md) | provides accessibility to `proxy` | | ||
|
||
## Example | ||
|
||
```cpp | ||
#include <iostream> | ||
|
||
#include "proxy.h" | ||
|
||
struct IntConvertible : pro::facade_builder | ||
::add_convention<pro::conversion_dispatch, int() const> | ||
::build {}; | ||
|
||
int main() { | ||
pro::proxy<IntConvertible> p = pro::make_proxy<IntConvertible, short>(123); // p holds a short | ||
std::cout << static_cast<int>(*p) << "\n"; // Prints: "123" | ||
} | ||
``` | ||
## See Also | ||
- [class `implicit_conversion_dispatch`](implicit_conversion_dispatch.md) | ||
- [class template `operator_dispatch`](operator_dispatch.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Class template `explicit_conversion_dispatch::accessor` | ||
|
||
```cpp | ||
// (1) | ||
template <class F, class C, class... Os> | ||
struct accessor { | ||
accessor() = delete; | ||
}; | ||
|
||
// (2) | ||
template <class F, class C, class... Os> | ||
requires(sizeof...(Os) > 1u && (std::is_constructible_v<accessor<F, C, Os>> && ...)) | ||
struct accessor<F, C, Os...> : accessor<F, C, Os>... { | ||
using accessor<F, C, Os>::operator return-type-of<Os>...; | ||
}; | ||
|
||
// (3) | ||
template <class F, class C> | ||
struct accessor<F, C, T() cv ref noex> { | ||
explicit operator T() cv ref noex; | ||
}; | ||
``` | ||
Let `SELF` be `std::forward<accessor cv ref>(*this)`. | ||
`(1)` The default implementation of `accessor` is not constructible. | ||
`(2)` When `sizeof...(Os)` is greater than `1`, and `accessor<F, C, Os>...` are default-constructible, inherits all `accessor<F, C, Os>...` types and `using` their `operator return-type-of<Os>`. `return-type-of<O>` denotes the *return type* of the overload type `O`. | ||
`(3)` When `sizeof...(Os)` is `1` and the only type `O` in `Os` is `T() cv ref noex`, provides an explicit `operator T()` with the same *cv ref noex* specifiers. `accessor::operator T()` is equivalent to `return proxy_invoke<C, T() cv ref noex>(access_proxy<F>(SELF))`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# `explicit_conversion_dispatch::operator()` | ||
|
||
```cpp | ||
template <class T> | ||
/* see below */ operator()(T&& value) noexcept; | ||
``` | ||
|
||
Returns a value that is implicitly convertible to any type `U` with expression `U{std::forward<T>(value)}` when `T` is explicitly convertible to type `U`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Class `implicit_conversion_dispatch` | ||
|
||
```cpp | ||
class explicit_conversion_dispatch; | ||
``` | ||
|
||
Class `implicit_conversion_dispatch` models a [dispatch](ProDispatch.md) type for implicit type conversion expressions. It meets the [*ProAccessible* requirements](ProAccessible.md) of applicable types. | ||
|
||
## Member Functions | ||
|
||
| Name | Description | | ||
| ------------------------------------------------------------ | --------------------------------------------------- | | ||
| (constructor) [nothrow] | constructs an `implicit_conversion_dispatch` object | | ||
| [`operator()`](implicit_conversion_dispatch/operator_call.md) | invokes the dispatch | | ||
|
||
## Member Types | ||
|
||
| Name | Description | | ||
| ------------------------------------------------------ | --------------------------------- | | ||
| [`accessor`](implicit_conversion_dispatch/accessor.md) | provides accessibility to `proxy` | | ||
|
||
## Example | ||
|
||
```cpp | ||
#include <iomanip> | ||
#include <iostream> | ||
|
||
#include "proxy.h" | ||
|
||
struct Runnable : pro::facade_builder | ||
::add_convention<pro::operator_dispatch<"()">, void()> | ||
::build {}; | ||
|
||
struct CopyableRunnable : pro::facade_builder | ||
::support_copy<pro::constraint_level::nontrivial> | ||
::add_facade<Runnable> | ||
::add_direct_convention<pro::implicit_conversion_dispatch, | ||
pro::proxy<Runnable>() const&, pro::proxy<Runnable>() &&> | ||
::build {}; | ||
|
||
int main() { | ||
pro::proxy<CopyableRunnable> p1 = pro::make_proxy<CopyableRunnable>( | ||
[] { std::cout << "Lambda expression invoked\n"; }); | ||
auto p2 = p1; // Copy construction | ||
pro::proxy<Runnable> p3 = p2; // Implicit conversion via const reference of pro::proxy<CopyableRunnable> | ||
std::cout << std::boolalpha << p2.has_value() << "\n"; // Prints: "true" | ||
// auto p4 = p3; // Won't compile because pro::proxy<Runnable> is not copy-constructible | ||
pro::proxy<Runnable> p5 = std::move(p2); // Implicit conversion via rvalue reference of pro::proxy<CopyableRunnable> | ||
std::cout << p2.has_value() << "\n"; // Prints: "false" | ||
(*p5)(); // Prints: "Lambda expression invoked" | ||
} | ||
``` | ||
## See Also | ||
- [class `explicit_conversion_dispatch`](explicit_conversion_dispatch.md) | ||
- [class template `operator_dispatch`](operator_dispatch.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Class template `implicit_conversion_dispatch::accessor` | ||
|
||
```cpp | ||
// (1) | ||
template <class F, class C, class... Os> | ||
struct accessor { | ||
accessor() = delete; | ||
}; | ||
|
||
// (2) | ||
template <class F, class C, class... Os> | ||
requires(sizeof...(Os) > 1u && (std::is_constructible_v<accessor<F, C, Os>> && ...)) | ||
struct accessor<F, C, Os...> : accessor<F, C, Os>... { | ||
using accessor<F, C, Os>::operator return-type-of<Os>...; | ||
}; | ||
|
||
// (3) | ||
template <class F, class C> | ||
struct accessor<F, C, T() cv ref noex> { | ||
operator T() cv ref noex; | ||
}; | ||
``` | ||
Let `SELF` be `std::forward<accessor cv ref>(*this)`. | ||
`(1)` The default implementation of `accessor` is not constructible. | ||
`(2)` When `sizeof...(Os)` is greater than `1`, and `accessor<F, C, Os>...` are default-constructible, inherits all `accessor<F, C, Os>...` types and `using` their `operator return-type-of<Os>`. `return-type-of<O>` denotes the *return type* of the overload type `O`. | ||
`(3)` When `sizeof...(Os)` is `1` and the only type `O` in `Os` is `T() cv ref noex`, provides an implicit `operator T()` with the same *cv ref noex* specifiers. `accessor::operator T()` is equivalent to `return proxy_invoke<C, T() cv ref noex>(access_proxy<F>(SELF))`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# `implicit_conversion_dispatch::operator()` | ||
|
||
```cpp | ||
template <class T> | ||
T&& operator()(T&& value) noexcept; | ||
``` | ||
|
||
Returns `std::forward<T>(value)`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.