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

Allowing formatting non-copyable ranges. #3290

Merged
merged 4 commits into from
Jan 27, 2023

Conversation

brevzin
Copy link
Contributor

@brevzin brevzin commented Jan 26, 2023

Fixes #3286

@brevzin
Copy link
Contributor Author

brevzin commented Jan 26, 2023

Some windows build is complaining about noncopyable_range<int> & being non-formattable, but I'm not sure why. Do you know what version "(windows-2019, x64, v140, 14)" corresponds to on compiler-explorer? Could try to repro something there.

@mwinterb
Copy link
Contributor

It's not an exact match, but the general "era" matches "x64 msvc v19.0 (WINE)".

@brevzin
Copy link
Contributor Author

brevzin commented Jan 26, 2023

wat: https://godbolt.org/z/b9TYxqh6s

namespace my {
namespace detail {
    template <typename... > using void_t = void;
}
}

template <typename T>
struct has_mutable_begin_end<
    T, 
    #if 1
    fmt::detail::void_t<
    #else
    my::detail::void_t<
    #endif
        decltype(fmt::detail::range_begin(std::declval<T>()))
        , decltype(fmt::detail::range_end(std::declval<T>()))
        #if 0
        , int
        #endif
        >>
    : std::true_type {};

static_assert(has_mutable_begin_end<noncopyable_range>::value, "");

If I use my::detail::void_t, this works.

If I use fmt::detail::void_t, which is ... the same thing as my::detail::void_t, it fails. Unless I add the extra int at the end, in which case it works?

Copy link
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

include/fmt/ranges.h Show resolved Hide resolved
@vitaut vitaut merged commit 05e3a92 into fmtlib:master Jan 27, 2023
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 this pull request may close these issues.

Can't format move-only ranges
3 participants