Some compilation problems
Opened this issue · 0 comments
kobtsev commented
std::convertible_to evaluates to false for same types of rd::expected<void, E>
Checked on:
msvc (cl 19.35.32215) /std:c++20
clang (15.0.0) -std=c++20
Some code to explain below:
godbolt clang 15 - issue 1
#include <concepts>
#include <system_error>
#include <rd/expected.hpp>
template <typename T>
using result = rd::expected<T, std::error_code>;
static_assert(std::convertible_to<result<std::size_t>, result<int>>); // successfully, ok
static_assert(std::convertible_to<result<void>, result<void>>); // failure, why?
Second assertion failed, Why can't identical rd::expected types be converted to each other? Is there a semantic reason for this behavior?
It may be related to another issue:
godbolt clang 15 - issue 2
#include <system_error>
#include <concepts>
#include <span>
#include <variant>
#include <rd/expected.hpp>
template <typename T>
using result = rd::expected<T, std::error_code>;
template <typename T>
using raw_result = std::variant<T, rd::unexpected<std::error_code>>;
struct data_header {
std::size_t data_length;
static raw_result<data_header> from_buffer(std::span<std::byte> buffer) noexcept; // compile
};
struct tpkt_header {
std::size_t length;
static result<tpkt_header> from_buffer(std::span<std::byte> buffer) noexcept; // won't compile
};