Add mi_attr_nodiscard_if_cpp20 and mark mi_stl_allocator::allocate overloads as such

This commit is contained in:
RealKC 2020-01-24 20:26:42 +02:00 committed by GitHub
parent 76e727f7d1
commit 9b1ca1d0e7
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,8 +20,14 @@ terms of the MIT license. A copy of the license can be found in the file
#else
#define mi_attr_noexcept throw()
#endif
#if __cplusplus > 201703L //C++20
#define mi_attr_nodiscard_if_cpp20 [[nodiscard]]
#else
#define mi_attr_nodiscard_if_cpp20
#endif
#else
#define mi_attr_noexcept
#define mi_attr_nodiscard_if_cpp20
#endif
#ifdef _MSC_VER
@ -381,8 +387,8 @@ template<class T> struct mi_stl_allocator {
void deallocate(T* p, size_type) { mi_free(p); }
#if (__cplusplus >= 201703L) // C++17
T* allocate(size_type count) { return static_cast<T*>(mi_new_n(count, sizeof(T))); }
T* allocate(size_type count, const void*) { return allocate(count); }
mi_attr_nodiscard_if_cpp20 T* allocate(size_type count) { return static_cast<T*>(mi_new_n(count, sizeof(T))); }
mi_attr_nodiscard_if_cpp20 T* allocate(size_type count, const void*) { return allocate(count); }
#else
pointer allocate(size_type count, const void* = 0) { return static_cast<pointer>(mi_new_n(count, sizeof(value_type))); }
#endif