Skip to content

unique reference implementation in C++ (similar to std::unique_ptr)

License

Notifications You must be signed in to change notification settings

optframe/unique_ref

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unique_ref

unique reference implementation in C++ (similar to unique_ptr)

How to use it

Just #include "unique_ptr.hpp", it's a single header library!

You can import "unique_ptr" namespace using unique_ptr::uref to get uref class, or just use it like unique_ptr::uref<MyClass> obj to create MyClass& obj equivalent.

What is the advantage over regular reference?

This should be used when you cannot really stack alloc your object, but still don't want to use a pointer... if you use uref we will manage the memory for you (using std::unique_ptr in the background).

Use uref or ucref?

Note that one can use ucref if you have concrete type. This is safer and allows a nice conversion operator (not possible on uref).

C++ Requirements

C++14 standard is required (for make_unique).

License

This project is MIT licensed, so feel free to use and share it!

2020

Releases

No releases published

Packages

No packages published