can't swap absl::FixedArray
Opened this issue · 2 comments
Describe the issue
You can't swap an absl::FixedArray<T>
. There is neither a member function nor does the default std::swap
work:
https://godbolt.org/z/3foo8xaPK
Steps to reproduce the problem
see above
What version of Abseil are you using?
trunk
What operating system and version are you using?
godbolt
What compiler and version are you using?
clang 17.0.1
What build system are you using?
godbolt
Additional context
see also #1571
I'm not sure the typical use cases for FixedArray
are cases for which having a swap
method makes sense. FixedArray
is usually used for putting a small array on the stack, but with an extent determined at runtime. How does swapping two FixedArray
s of differing sizes that are backed with stack memory work? I suspect if you are trying to swap, absl::InlinedVector
is a better choice. Can you describe the use case?
My use case is that I need a lot of usually very small arrays which don't need to be resizable and I thought that absl::FixedArray
would be a nice fit for that. absl::InlinedVector
has the extra capacity that I don't need. But since you can't swap an absl::FixedArray
you can't really use that thing for pretty much anything besides local variables.