I am wanting to confirm that I am correctly using std::launder(...) ensuring that I correctly understand its usage.
I am creating a Result<U,E> in C++ based off of Rust's implementation.
template <typename E>
class ResultStorage<void, E, std::enable_if_t<std::is_trivially_destructible_v<E>>> {
    using type = typename std::aligned_storage<sizeof(E), alignof(E)>::type;
public:
    explicit constexpr ResultStorage(const Ok<void>&) noexcept : tag_(ResultTag::OK) {}
    explicit constexpr ResultStorage(const Ok<void>&&) noexcept : tag_(ResultTag::OK) {}
    explicit constexpr ResultStorage(const Err<E>& err) noexcept(std::is_nothrow_copy_constructible<E>())
        : tag_(ResultTag::ERR) {
        new (&error_) E(err.get_error());
    }
    explicit constexpr ResultStorage(const Err<E>&& err) noexcept(std::is_nothrow_move_constructible<E>())
        : tag_(ResultTag::ERR) {
        new (&error_) E(std::move(err.get_error()));
    }
    ~ResultStorage() = default;
    [[nodiscard]] constexpr E& get_error() & noexcept {
        assert_err(tag_);
        return *std::launder(reinterpret_cast<E*>(&error_));
    }
    
    // Code omitted for brevity
private:
    ResultTag tag_;
    type error_;
    template <typename Rv, typename Ev>
    friend class result::Result;
};
In the code I use using type = typename std::aligned_storage<sizeof(E), alignof(E)>::type; as my storage type. It is my belief that I need to use std::launder(...) when I return the error type from the function like so:
    [[nodiscard]] constexpr E& get_error() & noexcept {
        assert_err(tag_);
        return *std::launder(reinterpret_cast<E*>(&error_));
    }
The reason that I believe I need to use std::launder(...) is because since the incoming error type may be a struct possibly with a const value then it appears that if I do not use std::launder(...) then on first initialization it will refer to the const member value and if I was to reuse this allocated storage it would always refer to the initial const member value.
I have a rudimentary understanding of std::launder so an explanation of what circumstances require its usage would be appreciated. I have looked at the cppreference for this function but still find it rather mystifying.
Note: the full impl can be found on github.