Comments (4)
If I understand correctly, proxy
already provides the capability. You can simply instantiate a proxy<F>
with any raw pointer type P
(although proxy<F>
still has nontrivial move ctor and dtor, it behaves like a raw pointer).
If proxy<F>
is intended not to take any ownership for all P
, it is allowed to fine tune performance like std::function_ref
does. Lifetime semantics is associated with the definition of a facade (F::constraints
). If you are using PRO_DEF_FACADE
to define a facade, the constraints can be specified on the 3rd parameter, e.g.,
PRO_DEF_MEMBER_DISPATCH(Draw, void(std::ostream& out));
PRO_DEF_FACADE(DrawableRef, Draw, pro::trivial_ptr_constraints);
proxy<DrawableRef>
will have trivial copy ctor and move ctor, but it can no longer hold any smart pointers (e.g., std::unique_ptr
std::shared_ptr
or pro::details::sbo_ptr
).
from proxy.
That's not the same: a function_ref-like thingy does not need an SBO (or heap allocation) for any kind of target object - as it references it directly (as opposed to owning it) - it can/should be able to bind to a temprary (function argument).
A reference to a trivial proxy<> has two indirections: reference to the proxy and then a reference to the vtable (and possibly an additional one to the target if it did not fit into the SBO storage).
trivial_ptr_constraints will make proxy the size of two pointers, like function_ref but will require a heap allocation and a nontrivial destructor for larger-than-a-pointer targets or not support those at all.
from proxy.
trivial_ptr_constraints will make proxy the size of two pointers, like function_ref but will require a heap allocation and a nontrivial destructor for larger-than-a-pointer targets or not support those at all.
In the design of proxy
, if trivial_ptr_constraints
is specified in a facade
definition F
, proxy<F>
is a trivial type. It is covered in our unit tests.
from proxy.
The dereferencing of small vtable is triaged as a QoI issue (filed #69).
from proxy.
Related Issues (20)
- Create Nuget package and publish it during release runs. HOT 1
- Add links to executable sample code in README
- Test targets compile failed for the [-Werror=uninitialized] compile option for non MSVC compiler(gcc11.2) HOT 5
- Differentiate interface abstraction from const member function HOT 3
- destructor call twice HOT 1
- C++ version support HOT 1
- how about memory usage when compare to default virtual-table implementation ? HOT 1
- Question: reducing boilerplate? Avoiding multiple pro::dispatch? HOT 5
- How to create a proxy object that is composed of another proxy object of the same type? HOT 2
- Function pointer can't be used to create a proxy
- Time to revise the name of constraints
- Lack support of overload resolution among multiple existing abstractions
- Compilation error on MSVC 19.36 HOT 1
- [FR] noexcept prototypes/signatures HOT 3
- [FR] SBO-only targets HOT 2
- [FR] Add std::function::target() equivalent HOT 1
- [FR] operator bool HOT 1
- [QoI] When the metadata of proxy is small enough, dereferencing the metadata can be eliminated
- What's the performance comparing to inheritance with virtual function? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proxy.