cginternals / globjects

C++ library strictly wrapping OpenGL objects.
https://globjects.org
MIT License
539 stars 59 forks source link

Weak ptr (closes #121) #275

Closed scheibel closed 9 years ago

mrzzzrm commented 9 years ago

What's the purpose of the Reference<T> wrapper? Some doc may be helpful. (And maybe std::reference_wrapper<T> can provide the same?)

scheibel commented 9 years ago

Although the name suggests, Reference is not comparable to std::reference_wrapper. The Reference class should contain a Referenced instance, i.e. a pointer to a pointer.

mrzzzrm commented 9 years ago

Okay, just being curious here: Why would such a wrapper be useful? Why not just use a pointer if that is all that it contains and it doesn't add functionality on top of it?

scheibel commented 9 years ago

@mrzzzrm: If no default ownership for raw pointers exists for your project, then a user may not know the ownership of a pointer.

@all: seems like we rewrite the complete ownership of pointers in globjects and we will strive for single use-case, writer-driven pointer ownership with strong focus on arbitrary ownership for pointers. This means, that we want to use strong ownership (unique_ptr) as often as possible, shared ownership (shared_ptr) sometimes where needed, distributed ownership (ref_ptr) never and no ownership (raw pointer) consequently and as often as possible.