using namespace boost::container;
using namespace boost::container::pmr;
-std::size_t allocation_count = 0;
-
#ifdef BOOST_MSVC
#pragma warning (push)
#pragma warning (disable : 4290)
#endif
-#if defined(BOOST_GCC) && (BOOST_GCC >= 40700) && (__cplusplus >= 201103L)
+#if __cplusplus >= 201103L
#define BOOST_CONTAINER_NEW_EXCEPTION_SPECIFIER
#define BOOST_CONTAINER_DELETE_EXCEPTION_SPECIFIER noexcept
#else
#pragma GCC diagnostic ignored "-Wsized-deallocation"
#endif
+//ASAN does not support operator new overloading
+#ifndef BOOST_CONTAINER_ASAN
+
+std::size_t allocation_count = 0;
+
void* operator new[](std::size_t count) BOOST_CONTAINER_NEW_EXCEPTION_SPECIFIER
{
++allocation_count;
return std::free(p);
}
+#endif //BOOST_CONTAINER_ASAN
+
#ifdef BOOST_MSVC
#pragma warning (pop)
#endif
+#ifndef BOOST_CONTAINER_ASAN
+
void test_new_delete_resource()
{
//Make sure new_delete_resource calls new[]/delete[]
BOOST_TEST(memcount == allocation_count);
}
+#endif //BOOST_CONTAINER_ASAN
+
void test_null_memory_resource()
{
//Make sure it throw or returns null
int main()
{
+ #ifndef BOOST_CONTAINER_ASAN
test_new_delete_resource();
+ #endif
test_null_memory_resource();
test_default_resource();
return ::boost::report_errors();