Created
September 1, 2020 02:07
-
-
Save vinniefalco/c999a693e46e2dec072c68ed60068f73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Constructor | |
This constructs a non-owning pointer that | |
points to the specified memory resource `r`. | |
The caller is responsible for maintaining the | |
lifetime of the pointed-to @ref memory_resource. | |
@par Constraints | |
@code | |
std::is_convertible< T*, memory_resource* >::value == true | |
@endcode | |
@par Preconditions | |
@code | |
r != nullptr | |
@endcode | |
@par Exception Safety | |
No-throw guarantee. | |
@param r A pointer to the memory resource to use. | |
This may not be null. | |
*/ | |
template<class T | |
#ifndef BOOST_JSON_DOCS | |
, class = typename std::enable_if< | |
std::is_convertible<T*, | |
memory_resource*>::value>::type | |
#endif | |
> | |
storage_ptr(T* r) noexcept | |
: i_(reinterpret_cast<std::uintptr_t>( | |
static_cast<memory_resource *>(r)) + | |
(json::is_deallocate_trivial<T>::value ? 2 : 0)) | |
{ | |
BOOST_ASSERT(r); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment