Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md and replaced std::popcount() with std::has_single_bit() #64

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ If so, this library is for you. 😉

For decades, object-based virtual table has been a de facto implementation of runtime polymorphism in many (compiled) programming languages. There are many drawbacks in this mechanism, including life management (because each object may have different size and ownership) and reflection (because it is hard to balance between usability and memory allocation). To workaround these drawbacks, some languages like Java or C# choose to sacrifice performance by introducing GC to facilitate lifetime management, and JIT-compile the source code at runtime to generate full metadata. We improved the theory and implemented as a C++ library without sacrificing performance, proposed to merge into the C++ standard.

The "proxy" is a single-header, cross-platform C++ library that Microsoft uses to make runtime polymorphism easier to implement and faster. Please find the design details at https://wg21.link/p0957.
The "proxy" is a single-header, cross-platform C++ library that Microsoft uses to make runtime polymorphism easier to implement and faster. Please find the design details at https://wg21.link/p3086.
mingxwa marked this conversation as resolved.
Show resolved Hide resolved

## Quick start

Expand All @@ -24,8 +24,8 @@ The majority of the library is defined in namespace `pro`. Some macros are provi
// Abstraction (poly is short for polymorphism)
namespace poly {

PRO_DEF_MEMBER_DISPATCH(Draw, void(std::ostream&));
PRO_DEF_MEMBER_DISPATCH(Area, double());
PRO_DEF_MEMBER_DISPATCH(Draw, void(std::ostream& out));
PRO_DEF_MEMBER_DISPATCH(Area, double() noexcept);
PRO_DEF_FACADE(Drawable, PRO_MAKE_DISPATCH_PACK(Draw, Area));

} // namespace poly
Expand All @@ -37,7 +37,7 @@ class Rectangle {
{ out << "{Rectangle: width = " << width_ << ", height = " << height_ << "}"; }
void SetWidth(double width) { width_ = width; }
void SetHeight(double height) { height_ = height; }
double Area() const { return width_ * height_; }
double Area() const noexcept { return width_ * height_; }

private:
double width_;
Expand Down Expand Up @@ -139,7 +139,7 @@ int main() {
}
```

Please find more details and discussions in the spec. The complete version of the "drawable" demo could be found in [tests/proxy_integration_tests.cpp](tests/proxy_integration_tests.cpp) (also available on [Compiler Explorer](https://godbolt.org/z/5a3jeE1M8)).
Please find more details and discussions in the spec. The complete version of the "drawable" demo could be found in [tests/proxy_integration_tests.cpp](tests/proxy_integration_tests.cpp) (also available on [Compiler Explorer](https://godbolt.org/z/voEacxT76)).

## Minimum requirements for compilers

Expand Down
2 changes: 1 addition & 1 deletion proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ template <class F>
} &&
std::is_same_v<decltype(F::constraints),
const proxiable_ptr_constraints> &&
std::popcount(F::constraints.max_align) == 1u &&
std::has_single_bit(F::constraints.max_align) &&
F::constraints.max_size % F::constraints.max_align == 0u &&
(std::is_void_v<typename F::reflection_type> ||
std::is_trivially_copyable_v<typename F::reflection_type>))
Expand Down
Loading