Skip to content

Commit a1f0362

Browse files
bugfix fast_io::list (#1223)
* bugfix fast_io::list * Drop deallocate, use deallocate_n instead
1 parent fe46a76 commit a1f0362

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

include/fast_io_dsal/impl/list.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ class list
457457
}
458458
else
459459
{
460-
typed_allocator_type::deallocate(ptr, 1);
460+
typed_allocator_type::deallocate_n(ptr, 1);
461461
}
462462
}
463463
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <fast_io_dsal/list.h>
2+
#include <fast_io.h>
3+
4+
struct X {
5+
X() {
6+
::fast_io::println("default");
7+
}
8+
9+
X(X const&) {
10+
::fast_io::println("copy");
11+
}
12+
13+
X(X&&) {
14+
::fast_io::println("move");
15+
}
16+
17+
~X() {
18+
::fast_io::println("destruct");
19+
}
20+
21+
X& operator=(X const&) {
22+
::fast_io::println("copy assign");
23+
return *this;
24+
}
25+
26+
X& operator=(X&&) {
27+
::fast_io::println("move assign");
28+
return *this;
29+
}
30+
};
31+
32+
int main() {
33+
// TODO copy X here, can it be fixed? (caused by std::initilizer_list)
34+
::fast_io::list<X> const l1{X{}};
35+
36+
return 0;
37+
}

0 commit comments

Comments
 (0)