Unlike STL and std::basic_string
, there is no default allocator for std::function
. Why?
There is no default allocator for std::function
in C++11.
But this article(https://learn.microsoft.com/en-us/cpp/standard-library/allocators?view=msvc-160) holds the opposite opinion, which says that:
In C++11 all the Standard Library types and functions that take an allocator type parameter support the minimal allocator interface, including
std::function
,shared_ptr
,allocate_shared()
, andbasic_string
.
template< class Alloc >
function( std::allocator_arg_t, const Alloc& alloc,
std::nullptr_t ) noexcept;
template<
class CharT,
class Traits = std::char_traits<CharT>,
class Allocator = std::allocator<CharT>
> class basic_string;
template<class T,
class Allocator = std::allocator<T>
> class vector;