-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
This provides a hint to the compiler that the lifetime of the memory resource is bound to the lifetime of the returned strong_ptr. That should help identify simple cases where the lifetime of the memory resources is less than that of the strong_ptr its bound to. This can provide a better diagnostic to users at compile time rather than telling the user at runtime that their application terminated due to a resource leak.
We can adopt a macro for selecting the correct attribute for the system:
#ifndef __has_cpp_attribute
#define lifetime_bound
#elif __has_cpp_attribute(clang::lifetimebound)
#define lifetime_bound [[clang::lifetimebound]]
#elif __has_cpp_attribute(msvc::lifetimebound)
#define lifetime_bound [[msvc::lifetimebound]]
#elif __has_cpp_attribute(lifetimebound)
#define lifetime_bound [[lifetimebound]]
#else
#define lifetime_bound
#endifMetadata
Metadata
Assignees
Labels
No labels