forked from boostorg/container
Add support for [[nodiscard]]:
- Decorate container and allocator functions. - Make sure to disable warnings in tests - Update doxygen documentation to support it
This commit is contained in:
1 parent
8a2444201a
commit
0a0ad0009e
22 files changed
+1096
-569
No files matched your search
@@ -177,7 +177,7 @@ class allocator
|
||||
//!Throws std::bad_alloc if there is no enough memory
|
||||
//!If Version is 2, this allocated memory can only be deallocated
|
||||
//!with deallocate() or (for Version == 2) deallocate_many()
|
||||
pointer allocate(size_type count, const void * hint= 0)
|
||||
BOOST_CONTAINER_ATTRIBUTE_NODISCARD pointer allocate(size_type count, const void * hint= 0)
|
||||
{
|
||||
(void)hint;
|
||||
if(count > size_type(-1)/(2u*sizeof(T)))
|
||||
@@ -205,19 +205,21 @@ class allocator
|
||||
|
||||
//!An allocator always compares to true, as memory allocated with one
|
||||
//!instance can be deallocated by another instance
|
||||
friend bool operator==(const allocator &, const allocator &) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
BOOST_CONTAINER_ATTRIBUTE_NODISCARD
|
||||
friend bool operator==(const allocator &, const allocator &) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{ return true; }
|
||||
|
||||
//!An allocator always compares to false, as memory allocated with one
|
||||
//!instance can be deallocated by another instance
|
||||
BOOST_CONTAINER_FORCEINLINE friend bool operator!=(const allocator &, const allocator &) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
|
||||
friend bool operator!=(const allocator &, const allocator &) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{ return false; }
|
||||
|
||||
//!An advanced function that offers in-place expansion shrink to fit and new allocation
|
||||
//!capabilities. Memory allocated with this function can only be deallocated with deallocate()
|
||||
//!or deallocate_many().
|
||||
//!This function is available only with Version == 2
|
||||
pointer allocation_command(allocation_type command,
|
||||
BOOST_CONTAINER_ATTRIBUTE_NODISCARD pointer allocation_command(allocation_type command,
|
||||
size_type limit_size,
|
||||
size_type &prefer_in_recvd_out_size,
|
||||
pointer &reuse)
|
||||
@@ -236,7 +238,7 @@ class allocator
|
||||
//!Memory must not have been allocated with
|
||||
//!allocate_one or allocate_individual.
|
||||
//!This function is available only with Version == 2
|
||||
size_type size(pointer p) const BOOST_NOEXCEPT_OR_NOTHROW
|
||||
BOOST_CONTAINER_ATTRIBUTE_NODISCARD size_type size(pointer p) const BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
return dlmalloc_size(p);
|
||||
@@ -246,7 +248,7 @@ class allocator
|
||||
//!must be deallocated only with deallocate_one().
|
||||
//!Throws bad_alloc if there is no enough memory
|
||||
//!This function is available only with Version == 2
|
||||
BOOST_CONTAINER_FORCEINLINE pointer allocate_one()
|
||||
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE pointer allocate_one()
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
return this->allocate(1);
|
||||
@@ -273,7 +275,8 @@ class allocator
|
||||
|
||||
//!Deallocates memory allocated with allocate_one() or allocate_individual().
|
||||
//!This function is available only with Version == 2
|
||||
BOOST_CONTAINER_FORCEINLINE void deallocate_individual(multiallocation_chain &chain) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
BOOST_CONTAINER_FORCEINLINE
|
||||
void deallocate_individual(multiallocation_chain &chain) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
return this->deallocate_many(chain);
|
||||
|
||||
Reference in new issue
Block a user