Skip to content

[deque] fix: constexpr support for deque in C++23#1281

Open
SekaiArendelle wants to merge 6 commits into
cppfastio:nextfrom
SekaiArendelle:constexpr-deque
Open

[deque] fix: constexpr support for deque in C++23#1281
SekaiArendelle wants to merge 6 commits into
cppfastio:nextfrom
SekaiArendelle:constexpr-deque

Conversation

@SekaiArendelle

Copy link
Copy Markdown

Summary

  • Add constexpr allocation/deallocation paths (using new[]/delete[]) in deque for C++26 constant evaluation
  • Fix deque_destroy_trivial_common_align null-pointer guard and controller deallocation in consteval
  • Fix overlapped_copy_trivial to use construct_at on output in consteval context
  • Guard __builtin_operator_new/__builtin_operator_delete with FAST_IO_HAS_BUILTIN for portability
  • Replace __builtin_is_constant_evaluated with #if __cpp_if_consteval + if consteval pattern
  • Add constexpr deque test (push/pop/back/front, copy/move/assign/swap, iterators, growth)

- Add null-pointer guard in deque_destroy_trivial_common_align consteval
- Fix controller array deallocation to use typed allocator, matching allocation method
- Use construct_at in overlapped_copy_trivial for constexpr output
- Add consteval paths in deque allocation functions using new/delete[] for ctfe
- Add constexpr deque tests (push, pop, copy, move, assign, swap, iterators)
@SekaiArendelle SekaiArendelle changed the title [deque] fix: constexpr support for deque in C++26 [deque] fix: constexpr support for deque in C++23 Jun 14, 2026
@SekaiArendelle

Copy link
Copy Markdown
Author

Seems the compiler inside ci is quite old. To prove my patch can work properly, following is what I copy-paste from my terminal:

PS D:\projects\fast_io> clang++ .\tests\0026.container\0003.deque\constexpr.cc -o .\build\test.exe -std=c++26 -I .\include\ -lntdll
PS D:\projects\fast_io> clang++ .\tests\0026.container\0003.deque\constexpr.cc -o .\build\test.exe -std=c++23 -I .\include\ 
PS D:\projects\fast_io> g++ .\tests\0026.container\0003.deque\constexpr.cc -o .\build\test.exe -std=c++23 -I .\include\ 
PS D:\projects\fast_io> clang++ .\tests\0026.container\0003.deque\constexpr.cc -o .\build\test.exe -std=c++23 -I .\include\ -fexperimental-new-constant-interpreter
PS D:\projects\fast_io> g++ --version
g++.exe (x86_64-win32-seh-rev0, Built by MinGW-Builds project) 16.1.0
Copyright (C) 2026 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

PS D:\projects\fast_io> clang++ --version
clang version 23.0.0git (https://github.com/llvm/llvm-project.git 4c4c1db7c69a6fda6cfa6bc6066bb09a433edc89)
Target: x86_64-unknown-windows-gnu
Thread model: posix
InstalledDir: D:/toolchains/llvm/x86_64-windows-gnu/bin
PS D:\projects\fast_io>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant