-
Notifications
You must be signed in to change notification settings - Fork 159
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
44 changed files
with
868 additions
and
135 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Class `bad_proxy_cast` | ||
|
||
```cpp | ||
class bad_proxy_cast : public std::bad_cast; | ||
``` | ||
A type of object to be thrown by the value-returning forms of [`proxy_cast`](basic_facade_builder/support_rtti.md) on failure. | ||
## Member Functions | ||
| Name | Description | | ||
| ------------- | ------------------------------------ | | ||
| (constructor) | constructs a `bad_proxy_cast` object | | ||
| (destructor) | destroys a `bad_proxy_cast` object | | ||
| `what` | returns the explanatory string | |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# `basic_facade_builder::support_format`<br />`basic_facade_builder::support_wformat` | ||
|
||
```cpp | ||
using support_format = basic_facade_builder</* see below */>; | ||
|
||
using support_wformat = basic_facade_builder</* see below */>; | ||
``` | ||
|
||
The member types `support_format` and `support_wformat` of `basic_facade_builder<Cs, Rs, C>` add necessary convention and reflection types to the template parameters, enabling specializations of [`std::formatter<proxy_indirect_accessor<F>, CharT>`](../formatter_proxy_indirect_accessor.md) where `F` is a [facade](../facade.md) type built from `basic_facade_builder`, `CharT` is `char` (if `support_format` is specified) or `wchar_t` (if `support_wformat` is specified). | ||
|
||
`support_format` and `support_wformat` also add constraints to a facade type `F` built from `basic_facade_builder`, requiring a contained value of `proxy<F>` be *formattable*. Formally, let `p` be a contained value of `proxy<F>`, `CharT` be `char` (if `support_format` is specified) or `wchar_t` (if `support_wformat` is specified), `T` be `std::decay_t<decltype(*std::as_const(p))>`, `std::formatter<T, CharT>` shall be an enabled specialization of `std::formatter`. | ||
|
||
## Example | ||
|
||
```cpp | ||
#include <format> | ||
#include <iostream> | ||
|
||
#include "proxy.h" | ||
|
||
struct Formattable : pro::facade_builder | ||
::support_format | ||
::build {}; | ||
|
||
int main() { | ||
pro::proxy<Formattable> p = pro::make_proxy<Formattable>(123); | ||
std::cout << std::format("{}", *p) << "\n"; // Prints: "123" | ||
std::cout << std::format("{:*<6}", *p) << "\n"; // Prints: "123***" | ||
} | ||
``` | ||
## See Also | ||
- [class template `std::formatter<proxy_indirect_accessor>`](../formatter_proxy_indirect_accessor.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,44 @@ | ||
# `basic_facade_builder::support_rtti`<br />`basic_facade_builder::support_indirect_rtti`<br />`basic_facade_builder::support_direct_rtti` | ||
|
||
```cpp | ||
using support_rtti = support_indirect_rtti; | ||
|
||
using support_indirect_rtti = basic_facade_builder</* see below */>; | ||
|
||
using support_direct_rtti = basic_facade_builder</* see below */>; | ||
``` | ||
|
||
The member types `support_rtti`, `support_indirect_rtti` and `support_direct_rtti` add necessary convention and reflection types to the template parameters, enabling [RTTI](https://en.wikipedia.org/wiki/Run-time_type_information) support for [`proxy<F>`](../proxy.md), where `F` is a [facade](../facade.md) type built from `basic_facade_builder`. For an RTTI-enabled facade `F`, non-member functions `proxy_typeid` (similar to [`std::any::type`](https://en.cppreference.com/w/cpp/utility/any/type)) and `proxy_cast` (similar to [`std::any_cast`](https://en.cppreference.com/w/cpp/utility/any/any_cast)) are available for [`proxy_indirect_accessor<F>`](../proxy_indirect_accessor.md) (if `support_rtti` or `support_indirect_rtti` is specified) or [`proxy<F>`](../proxy.md) (if `support_direct_rtti` is specified). | ||
|
||
## Non-Member Functions | ||
|
||
| Name | Description | | ||
| ---------------------------------------------- | ------------------------------------------ | | ||
| [`proxy_typeid`](support_rtti/proxy_typeid.md) | returns the `typeid` of the contained type | | ||
| [`proxy_cast`](support_rtti/proxy_cast.md) | type-safe access to the contained object | | ||
|
||
## Example | ||
|
||
```cpp | ||
#include <iostream> | ||
|
||
#include "proxy.h" | ||
|
||
struct RttiAware : pro::facade_builder | ||
::support_rtti | ||
::support_direct_rtti | ||
::build {}; | ||
|
||
int main() { | ||
int v = 123; | ||
pro::proxy<RttiAware> p = &v; | ||
std::cout << proxy_typeid(p).name() << "\n"; // Prints: "Pi" (assuming GCC) | ||
std::cout << proxy_cast<int*>(p) << "\n"; // Prints the address of v | ||
std::cout << proxy_typeid(*p).name() << "\n"; // Prints: "i" (assuming GCC) | ||
std::cout << proxy_cast<int>(*p) << "\n"; // Prints: "123" | ||
} | ||
``` | ||
## See Also | ||
- [`support_view`](support_view.md) |
Oops, something went wrong.