Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove std::aligned_union #54

Open
Cons-Cat opened this issue Nov 17, 2023 · 0 comments · May be fixed by #57
Open

Remove std::aligned_union #54

Cons-Cat opened this issue Nov 17, 2023 · 0 comments · May be fixed by #57

Comments

@Cons-Cat
Copy link

Cons-Cat commented Nov 17, 2023

std::aligned_union is an obsolete standard library feature, and its use causes Vookoo to not compile with a nightly libc++18 in C++2c mode.

/home/conscat/foo/Vookoo/include/vku/vku.hpp:1162:10: error: no template named 'aligned_union' in namespace 'std'
 1162 |     std::aligned_union<4, VkBool32, uint32_t, int32_t, float, double>::type
      |     ~~~~~^

Simply changing the compiler flag down to 20 makes this compile again. It was deprecated in 23 and removed in 2c.
https://en.cppreference.com/w/cpp/types/aligned_union
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1413r2.pdf

I think these definitions could be used to substitute the std identifiers, also.

namespace foo {
template <std::size_t S, typename... Ts>
struct aligned_union {
    static constexpr std::size_t alignment_value =
        std::max({alignof(Ts)...});

    struct type {
        alignas(alignment_value) char bytes[std::max({S, sizeof(Ts)...})];
    };
};

template <typename T>
using aligned_storage [[gnu::aligned(alignof(T))]] = std::byte[sizeof(T)];
} 
@Cons-Cat Cons-Cat linked a pull request Jun 4, 2024 that will close this issue
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 a pull request may close this issue.

1 participant