Alias template proxy_view
Class template observer_facade
Header:
proxy.h
Module:proxy
Namespace:pro::inline v4
Since: 3.2.0
template <facade F>
struct observer_facade;
template <facade F>
using proxy_view = proxy<observer_facade<F>>;
proxy_view<F> is a non-owning, trivially copyable, trivially relocatable view of an object that models proxiable_target<T, F>. It behaves like a proxy<F> except that it never owns the lifetime of the underlying object.
observer_facade<F> adapts an existing facade F for this non-owning use. The adaptation preserves only those parts of F that remain semantically valid when the storage is reduced to a single pointer and modifies substitution conversions so that view-ness is preserved (substitution that would have produced an owning proxy<G> instead produces a proxy_view<G>).
Member Types of observer_facade
Member Constants of observer_facade
Example
#include <cstdio>
#include <map>
#include <proxy/proxy.h>
template <class K, class V>
struct FMap
: pro::facade_builder //
::add_convention<pro::operator_dispatch<"[]">, V&(const K& key)> //
::build {};
int main() {
std::map<int, int> v;
pro::proxy_view<FMap<int, int>> p = &v;
(*p)[1] = 123;
printf("%d\n", v.at(1)); // Prints "123"
}
