diff --git a/include/fast_io_dsal/impl/list.h b/include/fast_io_dsal/impl/list.h index e58c566b..bb915424 100644 --- a/include/fast_io_dsal/impl/list.h +++ b/include/fast_io_dsal/impl/list.h @@ -457,7 +457,7 @@ class list } else { - typed_allocator_type::deallocate(ptr, 1); + typed_allocator_type::deallocate_n(ptr, 1); } } }; diff --git a/tests/0026.container/0002.list/list_init_rvalue.cc b/tests/0026.container/0002.list/list_init_rvalue.cc new file mode 100644 index 00000000..f598c45a --- /dev/null +++ b/tests/0026.container/0002.list/list_init_rvalue.cc @@ -0,0 +1,37 @@ +#include +#include + +struct X { + X() { + ::fast_io::println("default"); + } + + X(X const&) { + ::fast_io::println("copy"); + } + + X(X&&) { + ::fast_io::println("move"); + } + + ~X() { + ::fast_io::println("destruct"); + } + + X& operator=(X const&) { + ::fast_io::println("copy assign"); + return *this; + } + + X& operator=(X&&) { + ::fast_io::println("move assign"); + return *this; + } +}; + +int main() { + // TODO copy X here, can it be fixed? (caused by std::initilizer_list) + ::fast_io::list const l1{X{}}; + + return 0; +}