Skip to content

Commit df70f1c

Browse files
Use ptr_cast instead of std::launder
1 parent efaaa33 commit df70f1c

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

include/rfl/Result.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <string>
1313
#include <type_traits>
1414

15+
#include "internal/ptr_cast.hpp"
16+
1517
namespace rfl {
1618

1719
/// Defines the error class to be returned when something went wrong
@@ -398,27 +400,25 @@ class Result {
398400
}
399401

400402
T&& get_t() && noexcept {
401-
return std::move(*std::launder(reinterpret_cast<T*>(t_or_err_.data())));
403+
return std::move(*internal::ptr_cast<T*>(t_or_err_.data()));
402404
}
403405

404-
T& get_t() & noexcept {
405-
return *std::launder(reinterpret_cast<T*>(t_or_err_.data()));
406-
}
406+
T& get_t() & noexcept { return *internal::ptr_cast<T*>(t_or_err_.data()); }
407407

408408
const T& get_t() const& noexcept {
409-
return *std::launder(reinterpret_cast<const T*>(t_or_err_.data()));
409+
return *internal::ptr_cast<const T*>(t_or_err_.data());
410410
}
411411

412412
Error&& get_err() && noexcept {
413-
return std::move(*std::launder(reinterpret_cast<Error*>(t_or_err_.data())));
413+
return std::move(*internal::ptr_cast<Error*>(t_or_err_.data()));
414414
}
415415

416416
Error& get_err() & noexcept {
417-
return *std::launder(reinterpret_cast<Error*>(t_or_err_.data()));
417+
return *internal::ptr_cast<Error*>(t_or_err_.data());
418418
}
419419

420420
const Error& get_err() const& noexcept {
421-
return *std::launder(reinterpret_cast<const Error*>(t_or_err_.data()));
421+
return *internal::ptr_cast<const Error*>(t_or_err_.data());
422422
}
423423

424424
void move_from_other(Result<T>& _other) noexcept {

0 commit comments

Comments
 (0)