Paul Krill
Editor at Large

Microsoft unveils Proxy 4 library for polymorphic coding in C++

Library for runtime polymorphism adds reusable building blocks for composing facades, aliases for non-owning and weak references, and new helpers for creating shared and weak proxies.

Objects, geometric shapes, OOP
Credit: Anna Martyanova/Shutterstock

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.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a β€œBest Technology News Coverage” award from IDG.

More from this author