arximboldi / immer

Postmodern immutable and persistent data structures for C++ — value semantics at scale
https://sinusoid.es/immer
Boost Software License 1.0
2.48k stars 177 forks source link

Compiling in C++23 mode issues a deprecation warning for `std::aligned_storage`. #283

Closed nicola-gigante closed 4 months ago

nicola-gigante commented 4 months ago

First of all thanks for the awesome library!

The new LLVM/Clang 18 implemented the deprecation of std::aligned_storage in C++23 and therefore it warns the following when compiling a project using immer in C++23 mode:

.../immer/detail/util.hpp:40:1: error: 'aligned_storage<8, 8>' is deprecated [-Werror,-Wdeprecated-declarations]
   40 | using aligned_storage_for =

of course one can switch off the warning but ideally this would be avoided by stopping using std::aligned_storage.

There are some ways to avoid it as written here: https://stackoverflow.com/questions/71828288

The replacement in the SO answer cites std::byte, which came in C++17 afaik, but if immer wants to support C++14 it should be ok to just use char, so this means the line above would become something like:

template<typename T>
struct aligned_storage_for {
    alignas(T) char data[sizeof(T)] = { };
};

I can prepare a PR if you are interested in this fix.

arximboldi commented 4 months ago

Thank you! The suggested solution sounds good to me. Happy to accept a PR :)

nicola-gigante commented 4 months ago

Good! I'll work on it in the next days!