Microsoft has released Proxy 4, an update of its Proxy library for runtime polymorphism in the C++ language. The new release introduces building blocks for composing facades, aliases to express borrowing and weak ownership patterns, helpers for efficiently creating shared and weak proxies, and more.

Proxy 4 was announced August 19. Found on GitHub, Proxy is described as a header-only, cross-platform C++20 library for writing polymorphic code without the pain of inheritance or the limitations of traditional virtual functions.

Proxy 4 introduces convenient aliases for non-owning and weak references, proxy_view and weak_proxy. These are built atop the core proxyconcept, making it easier to express borrowing and weak ownership patterns in code, Microsoft said. For example, developers can use proxy_view to safely borrow an object without taking ownership, or weak proxy to build a weak reference that can be locked when necessary.

New make_proxy_shared and allocate_proxy_sharedAPIs in Proxy 4 allow developers to create shared and weak proxies efficiently, without the overhead of std::shared_ptr. These APIs use compact internal pointer types to ensure high performance and low memory usage, Microsoft said. Proxy 4 also introduces facade_aware_overload_t, which allows developers to define recursive conventions that refer to the facade itself without forcing early instantiation. This is especially useful for operator chaining patterns, like arithmetic or concatenation, that return new proxy objects of the same facade, according to Microsoft.

Alongside the Proxy 4 release, Microsoft introduced the Compiler Explorer, an online tool that allows developers to write and run Proxy code in their web browser.