keepalive

Small utility library to ensure a reference is emplaed on the stack.

The empty asm call is currently enough to force all current compilers to give up on trying to optimize the destructor out. If this becomes incorrect at some point, then a revisit is necessary.

Members

Functions

keepAlive
auto keepAlive(T val)

Create a guaranteed-stack-allocated reference. While the thing itself cannot be copied, it should be usable just like the reference that it wraps. Because of the destructor, it is guaranteed to be put on the stack.

Meta

License

Boost-1.0. See LICENSE.MD

Authors

Steven Schveighoffer